2

When creating a bookmarklet that opens a "fake popup" (similar to amazon's wishlist, pinterest, etc) why do people not use iframes instead of generating all the elements and removing all page styles from them? As far as I can tell:

Iframe pros:

  • can use browser mechanism for remembering password, etc
  • no 3rd party cookie issues
  • form submission is much simpler
  • much less javascript, which may possibly be broken by scripts etc on the page

Iframe cons:

  • cannot automatically close the popup (bookmarklet cannot read iframe content)
  • any page scripts must be run outside the iframe, then results passed in via GET param (iframe can't read page content)
  • ???

It seems to me that if you don't need the thing to close automatically, an iframe would be by far the better bet. Yet nobody seems to do this. Why not?

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
Mala
  • 14,178
  • 25
  • 88
  • 119
  • An iframe created via bookmarklet [can't read](http://www.phpied.com/firebug-console-for-ie/) the DOM of the parent document, that's strike three. – Paul Sweatte Jul 27 '12 at 00:37
  • the script could do the parsing and then pass that into the iframe via get parameters though, no? – Mala Aug 02 '12 at 00:22
  • Yes, that would work, but then any events inside the iframe would still have no effect on the parent document. – Paul Sweatte Aug 02 '12 at 01:41

1 Answers1

0

Here's why:

  • An iframe created via bookmarklet can't read the DOM of the parent document

  • Any events inside the iframe would still have no effect on the parent document

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265