Can a function defined in a bookmarklet be called from a page-level script?

Posted by Soviut on Stack Overflow See other posts from Stack Overflow or by Soviut
Published on 2010-01-23T20:37:37Z Indexed on 2010/05/19 16:40 UTC
Read the original article Hit count: 199

I have a bookmarklet that needs to open a new window/tab. In order to avoid the popup blocker, I need to call the window.open() method directly in the bookmarklet ie: at the browser-level.

However, I want to keep the bookmarklet updatable by loading external Javascript files. To do this, the bookmarklet needs to append script nodes to the DOM. If i were to put window.open() code in one of these externally loaded scripts, the popup blocker would block it since its page-level.

What I want to know is if I can create a wrapper function around window.open() in my bookmarklet, then call it from the externally loaded script? What is the scope and what are the permissions on a wrap such as this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about bookmarklet