0

window.location.href does not work to save the current web page url as a bookmark. Does anyone perhaps know why?

Thanks

1
  • 1
    What do you mean by "save as a bookmark"? Can you elaborate and show some code? Commented Feb 21, 2011 at 10:19

2 Answers 2

1

This code works in Firefox as well as IE.

function CreateBookmarkLink() {

 title = "Webpage Title"; 
 //or title = document.title

 url = "Webpage URL";
 //or url = location.href

if (window.sidebar) { // Mozilla Firefox Bookmark
    window.sidebar.addPanel(title, url,"");
} else if( window.external ) { // IE Favorite
    window.external.AddFavorite( url, title); }

}

Source

<a href="javascript:CreateBookmarkLink()" >Bookmark Page</a>
Sign up to request clarification or add additional context in comments.

1 Comment

sidebar.addPanel() is no more standard hence with the newest versions for firefox it's now deprecated and might not work anymore...
1

Use this code instead...

javascript:window.external.AddFavorite(location.href, document.title);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.