Forum Moderators: open
I would like to link to a dynamic page, which, as far as I can tell is only accessible by executing a javascript on a static html page (it then pulls all the elements together to create the dynamic page).
I would like to open the dynamic page in a new window, because it's an external resource, so I thought the best way to do this would be to open the static html page in a new window, then apply the javascript from that page onto the same window, thus leaving the reader looking at the dynamic document.
I know this would work theoretically, because I've tried just entering the javascript function alone into the address bar when I'm on the static html page and it brings up the dynamic page.
But how can I tell the browser to do this automatically?
So far I've tried linking to:
http://www.external.com/staticpage.html?javascript:newpage('id01'); okay, don't laugh, I knew this was a bit unlikely
and I've also tried using an onClick window.open javascript link for the [external.com...] (giving the window a name), followed by an onLoad event handler and trying to reload
javascript:newpage('id01'); into the address bar using the window name.
Nothing seems to work.
It doesn't seem like it ought to be that complex to open a new window and then, once that window has loaded, to enter a new url (or in this case bookmarklet) and refresh the window...?
You can't execute a javascript on another site from your page.
Sure you can... There are just limitations. The script on the other site can't access any of the elements on your page, but you can still use it to do basic things.
http://www.example.com/file.js
document.write("Hello World!");
Then in your document, just do:
<script src="http://www.example.com/file.js" type="text/javascript"></script>
Or...
http://www.example.com/file.js
function foobar(what) {
alert(what);
}
<script src="http://www.example.com/file.js" type="text/javascript"></script>
<script type="text/javascript">
foobar("this")
</script>
If you open a new window and change the value of document.location it will automatically display the new location.
This is pretty much what I want to do. I'm going to explain this again, because I think I explained it badly the first time.
1) If I am on [othersite.com...] and I type into the address bar:
javascript: bookmarklet(); then the dynamic page that I would like to link to springs up.
2) This means that the javascript code is linked to from page1.html (though I can't find it, it's been buried away somewhere, or is external and the reference has been hidden) and it's on othersite.com.
3) So I would like to bring up a new window containing [othersite.com...] and then, once page1.html has finished loading, automatically rewrite the URL from my page (using javascript) as
javascript: bookmarklet(); 4) I'm guessing this would have the (desired) identical effect as being on page1.html and entering
javascript: bookmarklet(); Sorry for explaining myself badly.
The page is on the other site.
The javascript is on the other site.
The dynamic page is on the other site.
All I want to do is enter the URL, wait for the page to finish loading, change the content of the address bar and refresh the page.
Thanks.
you can still use it to do basic things
document.write("<script type=\"text/JavaScript\"
src=\"http*//www.example.com/cgi.js?A="+escape(document.referrer)+"\"></"+"script>");
GGG
4) I'm guessing this would have the (desired) identical effect as being on page1.html and entering
javascript: bookmarklet();
into the address bar.
I wouldn't bet a lot of money on that ;)
If anything, just calling the function bookmarklet() (as in one of my examples) should do it... And that's a much safer route.
Is it still possible call a remote .js function from my page and have it act upon a remote page contained in a child window?
The relevant .js script is contained within the body of the static .html document (I found it eventually)which makes it more tricky...
...but even if the .js script was externally referenced I have no idea of how to make it act upon a page on another site rather than a page on my site.
To boot there seems to be a cgi form which the javascript is acting on and I don't know how to reference the form either.
I think I'll just give up. I'm not sure the site, excellent resource though it is, deserves a link when they make it this complicated...
I think they're either super-paranoid about spiders or one of the underlying concepts of hyperlinking has utterly passed them by.