• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
WebKit - javascript / DOM listeners only fire once
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

WebKit - javascript / DOM listeners only fire once


  • Subject: WebKit - javascript / DOM listeners only fire once
  • From: Darren Wheatley <email@hidden>
  • Date: Sun, 13 Feb 2011 14:02:59 +0000

Hi,

I have a Mac client application written in Cocoa / Objective-C that presents the user with a list of html documents in a table (master view), and when the user clicks on a row it loads the selected HTML page into a WebView (detail view).

Every HTML page has a listener on "click" that calls an Objective-C method.

When the application runs and the user clicks on the first row, everything works fine. The "click" event is trapped, and my Objective-C method is successfully called.

However, when the user clicks on a second (or subsequent) record and then a new HTML page is loaded in to the same WebView the listener on "click" never fires.

If the selected record is the first to be loaded it always works fine, so the problem is not one of bad HTML files. FYI, all files are largely identical.

I've boiled the problem down in a simple test application. It can be downloaded here - http://dl.dropbox.com/u/160638/Work/TCL/MapTest2.zip

NOTE: The test application outputs a message to the standard log, so you will need to check either the log window in Xcode or Console.app to see the Objective-C method call working (or not). The buttons along the top are in pairs, loading first from a local file, then an HTML page as a string, then pulling an HTML page from a web site.

From extensive searching I'm guessing that when I load the second HTML page into the WebView the previous page is retained somehow, and the two listeners on "click" are clashing in some way? Is that possible?

Can anyone recommend a way to load HTML pages in a WebView such that subsequent loads will work? Is there a way to ensure that any pages previously loaded into a WebView are fully unloaded before I load the second page?

Any suggestions you could make would be appreciated.

Regards

Darren.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: WebKit - javascript / DOM listeners only fire once
      • From: "Stephen J. Butler" <email@hidden>
  • Prev by Date: Re: Canceling NSInvocationOperation
  • Next by Date: Re: WebKit - javascript / DOM listeners only fire once
  • Previous by thread: Re: Canceling NSInvocationOperation
  • Next by thread: Re: WebKit - javascript / DOM listeners only fire once
  • Index(es):
    • Date
    • Thread