Alowing a user to browse a url and then get the end URL back using javascript
I have a button in a form which constructs a base google search url and then launches a browser window. I store a reference to the created window. What I want to be able to do is then get the href back from that window. Firebug tells me I am not allowed. e.g
<input onFocus='javascript:document.getElementById("url").value=subjectwin.location.href;' type="text" name="URL" id="url" value="<?php echo $_SESSION["session.events"]["eventLink"]; ?>" />
Here "subjectwin" is valid. So I guess it blocks me since that window might have another url in that the user chose. Is there some other workaround to get what I want?
Even if my approach is wrong, is there another one : bottom line being I want to开发者_C百科 get a selected url back into a field onmy form on one page from another.
This is not possible to do in the browser for security reasons: https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript
The only work around is to proxy all the requests through your own server (rewriting the links to point back to your server each time).
精彩评论