I'm writing a web-based game that involves clicking links on various sites on the internet. I know it sounds strange but the basic premise is that you start on my page where you click a link to some page on another site. You continue to follow links until you get to the page you are trying to reach. Think WikipediaGame.org. The difference being that I don't have control over the actual pages with the links.
What I need to be able to do is track all the links that they clicked, and when they get to the final page, I want to send them back to my site (or something along those lines).
Maybe a bookmarklet to send the current page to your site? That way the user would have complete control over the list of links shared with a minimal amount of work.
To make this cross-browser compatible -- I'm not sure if there is a way without writing a plugin for each browser. But, I could be wrong too :-)
If you want to just support Firefox, you could write a Greasmonkey script that would run on every page/site. But, that would limit the scope of your users.
I'm not sure you can accomplish this the way you're envisioning. Without writing a browser plugin, I would look at what sites like KeepVid are doing. They have you create a bookmark on your toolbar, and the bookmark url is this:
That essentially passes the url the user is presently on over to keepvid. If you use this concept, you can have your user click the bookmark button to register that url to you and you can collect that and pass the user back to where they were.
So i figured out what to do. I'm using an iframe like this:
<iframe src="Puzzle/ContinuePuzzle" />
I think you could accomplish something like what you want using an iframe.
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).
When the button on your page is pressed you could query the current state of the iframe…
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.
window.frames[iframeName] <br/> window.frames[iframeName].document <br/>
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.
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:
// IE5.5+ windows document.getElementById(iframeId).contentWindow document.getElementById(iframeId).contentWindow.document or, // DOM document.getElementById(iframeId).contentDocument
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.
Here is a good example of jQuery controlling an iframe
Hope that helps.