Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don’t know how you would inject JavaScript into someone else’s pages, which would then send you messages. That actually sounds like something a virus would do. <br/></p> <p>I think you could accomplish something like what you want using an iframe.<br/> A simple method would be to include an iframe preset to load the “start” location on your site, and then include a button on the outer page for the user to post back their current location (in the iframe). </p> <p>When the button on your page is pressed you could query the current state of the iframe…<br/> References to the window generated by the iframe and to the document loaded into the iframe can be obtained via the frames array using the name attribute. <br/></p> <pre><code> window.frames[iframeName] &lt;br/&gt; window.frames[iframeName].document &lt;br/&gt; </code></pre> <p>The frames array method of referencing has broad support, even among quite old browsers, as long as you attach a name attribute to the iframe. For best results, use both name and id. <br/></p> <p>For more up-to-date browsers, the document inside the iframe can also be referenced via contentWindow (IE win) and contentDocument (DOM) properties of the iframe element: <br/></p> <pre><code>// IE5.5+ windows document.getElementById(iframeId).contentWindow document.getElementById(iframeId).contentWindow.document or, // DOM document.getElementById(iframeId).contentDocument </code></pre> <p>EDIT: As the comments below suggest, it looks like most browsers prevent you from using an iframe this way. You can start a window anwhere you want, but you are not allowed to communicate with it if it is not on your same domain. I guess you could build a "Man in the Middle" scenerio, where you flow all the trafic through your server first, but that is not very practical. </p> <p>Here is a good example of jQuery controlling an iframe</p> <p><a href="http://wwwendt.de/tech/dynatree/doc/sample-iframe.html" rel="nofollow noreferrer">http://wwwendt.de/tech/dynatree/doc/sample-iframe.html</a></p> <p>Hope that helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload