Reputation: 2113
I'm trying to write a bookmarklet where it will redirect a user to a page, and after their page is loaded, it'll position the web page at a specific y-coordinate via JavaScript.
I know this is possible to do before you redirect, but is there a way to do it when after you have redirected, the page will then re-position itself at that location?
I can think of using an iFrame as a potential solution, but that's not exactly what I want.
Thanks!
Upvotes: 3
Views: 2721
Reputation: 4070
This method does not do exactly what you want, but it merge two(or more) function into one bookmarklet. To do this try separate another command using "javascript:" protocol. When you click the bookmarklet, it will redirect you to the URL specified. However, you must click bookmark again to run the second part.
Example of URL:
javascript:if(window.location!="http://www.example.com/"){window.location="http://www.example.com/"}; javascript:alert("Click bookmarklet again");
Upvotes: 3
Reputation: 15810
This cannot be done, due to the browser's security policy against XSS (cross-site scripting).
Even with an iframe, the browser will prevent the external window from scripting the inner window.
The best you can do is load the page, then click the bookmarklet.
Upvotes: 2