views:

193

answers:

3

I have an ASP.NET web page having a button in it. Clicking the button, a bookmark should be saved in the browser and when the user clicks the bookmark, it should surf to http://google.com.

How do I make sure that it works with almost all the standard browsers or at least with IE, Mozilla Firefox, Opera and Google Chrome.

Another case, I create a 2nd bookmark also in the same way. But when the user clicks upon the 2nd bookmark, it should run a piece of JavaScript code.

+1  A: 

Can't be done for security reasons. It used to be possible using a proprietary IE command but I think that ended in IE 7. Definitely impossible in the others.

Related discussion on Mozilla Developer Central

Pekka
Or at least giving an option for the user to add a bookmark i.e. is it possible to ask the user's permission to add it?
Arjun Vasudevan
@Arjun I think this (asking the user's permission) is what happens nowadays when you call `window.external.AddFavorite` in IE. I know of no other way to do this other than ask the user to please press Ctrl+D.
Pekka
+1  A: 

In Firefox as far as I know there is currently no function that adds a regular bookmark. Only a sidebar bookmark can be created in Firefox.

Here you can find a script that works for most browsers: http://labnol.blogspot.com/2006/01/add-to-favorites-ie-bookmark-firefox.html

As you can see at this line:

window.sidebar.addPanel(title, url,"");

it only adds a sidebar entry for Firefox, which is not very user friendly.

Kau-Boy
How to add a sidebar bookmark in Firefox?
Arjun Vasudevan
I added a link to an example and the Firefox sidebar code.
Kau-Boy
Another solution would be to use something like http://www.addthis.com which will give the user even more options to bookmark a page as he might not sit on his on PC to use a social bookmarking plugin in his browser.
Kau-Boy
A: 
Arjun Vasudevan
But this will (as I already explained) only add a sidebar for Firefox. And unforunately there is NO solution for Chrome or Safari.
Kau-Boy