Make javascript run on external link click?
Ok, lets say I have page.php. If i'm currently viewing page.php and I click this link:
<a href="#?call=friend.request&user_id=10&width=420&height=250">Link</a>
The javascript box will pop up. Success!
However, if I'm on a different page, and I link to
<a href="http://domain.com/page.php#?call=friend.request&user_id=10&开发者_StackOverflow社区width=420&height=250">Link</a>
The javascript box will not pop up when the page loads.
Any ideas?
I can't edit or find the javascript code that executes the said function, unfortunately.
That's not the idea of JS, so basically what you have to do is a check in the window.onload
event, so you can check the window.location
to search for the # string and then parse whatever you want.
As I said, that's not the general idea of JS, so it turn out to be a little messy.
You would have to run a function on page load which would inspect window.location.search (which provides access to the ?call=.... part) And then calls the same javascript that the links on your page.php are calling.
My guess is that linking to the page directly like that, it sees the ?
code as part of the querystring and not the hash thus making the hash value just an empty #
. Can you do this without the ?
in the hash value? Or you can try URL encoding it using %3F
.
<a href="http://domain.com/page.php#%3Fcall=friend.request&user_id=10&width=420&height=250">Link</a>
精彩评论