Bookmarklets: Bookmarklets and Frames - www.docjavascript.com | WebReference

Bookmarklets: Bookmarklets and Frames - www.docjavascript.com


Bookmarklets and Frames

When you run a script from a bookmark, via a bookmarklet, you are actually entering a javascript: URL in the browser's Location bar (Internet Explorer calls it an Address bar). If the current Web page in the browser's window consists of several frames, the script is executed as part of the parent window. For example, if you have a bookmarklet that counts the number of links on the current page, it will not work with a frame-based page.

If a javascript: URL appears in a link, it can refer to a specific frame if the link is located within that frame. However, if you then create a bookmarklet out of that link, you must remember that the bookmarklet executes at the topmost level of the page.

If you pay a visit to bookmarklets.com, you will notice that only some of the scripts are compatible with frame-based documents. They won't generate errors on such pages, but they won't do their job. Generally speaking, bookmarklets that deal with the content of the page will not work with frames, while those that deal with the current location or the browser's window will work flawlessly.

https://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: February 1, 1999
Revised: February 1, 1999

URL: https://www.webreference.com/js/column35/frames.html