Solved

Javascript Add to Bookmarks link

Posted on 2011-02-15
2
780 Views
Last Modified: 2012-05-11
Can someone please let me know how I can get the following script to work in chrome?

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

<a href="#" onclick="Javascript:bookmark('http://www.mysite.com/', 'Some Title')"><img alt="Add to favorites" src="http://www.myslte.com/images/favorites_bookmark.png" height="20" width="20"></a>

it works fine in firefox and IE.

Thanks

Mike
0
Comment
Question by:hungoveragain
2 Comments
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 200 total points
ID: 34899597
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 300 total points
ID: 34899768
chrome is goint to this part

} else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  }

and Chrome does not allow adding bookmarks by JS...
use this code:
<script>
function bookmark(url,title){
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if ((navigator.appName == "Netscape") && (!is_chrome)) {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape / Chrome) or CTRL-T (Opera) to bookmark");
  }
}
</script>

<a href="#" onclick="javascript:bookmark('http://www.mysite.com/', 'Some Title')"><img alt="Add to favorites" src="http://www.myslte.com/images/favorites_bookmark.png" height="20" width="20"></a>

Open in new window

0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question