views:

222

answers:

2

Hey SO,

I get the feeling that this is impossible, but is there a way to change what the url of my page will be if someone bookmarks it.

I ask because I'm running something in an Iframe, which isn't reflected in my URI. I was thinking maybe I could keep track of where the Iframe is in javascript, and then if they try to bookmark the page, I can put that JS into the URI they bookmark.

Is this possible?

+2  A: 

You could always create clickable "bookmark this" links you could change dynamically depending on whatever logic your iframe setup uses. That won't deal with traditional bookmarks (user clicks the star in FF, adds to favorites in IE).

For anything better than this, please post a more detailed explanation of what you are doing with the iframe, and the calling page.

code_burgar
+1  A: 

In short: no. Bookmark creation doesn't trigger a Javascript callback outside of rare cases like Firefox extensions.

If you want to insure that all your page content is available in a bookmarked version of the page, you'll need to add all the relevant state to the page URL. This could take the form of a session ID, encoded URL of the iframe content, or some other identifier, but it should be a unique, durable location, or else the bookmark will break eventually.

rcoder