Home arrow Tutorials arrow JavaScripts arrow Add url to Favorites / Bookmarks

Web Development

Welcome to Web Development section. Please choose a category. 
  • Hrvatski tutorijali
    Ovdje su objavljeni razni tutorijali na hrvatskom jeziku na temu PC, programiranje, web development, savjeti, trikovi, optreba racunala itd.
  • Tips / Tricks
    Articles about various tips and tricks concerning Windows, Linux and other OS usage.
  • JavaScripts
    Code snippets, tutorials and tricks for JavaScrip language.
  • PHP & MySQL
    Tutorials, code examples, tips and tricks for PHP and MySQL development.
  • Tutorials
    Place for tutorials about using various application in best and simplest way.
Add url to Favorites / Bookmarks PDF Print E-mail
(9 votes)

Most web browsers like Firefox (Ctrl+D), Opera (Ctrl+T) and IE (Ctrl+D) provide keyboard shortcuts to enable users bookmark their favorite pages.

But not every visitor is a power user, so for them, you can add a quick "Bookmark this page" link in all your pages. Clicking on the link prompts the user with a dialog box to add the specified URL to the Favorites list.

The javascript code mentioned on IE MSDN page doesn't work in other browsers.
window.external.AddFavorite(location.href, document.title);

The following modified version of "Add to Favorites" javascript code works across IE, Mozilla Firefox and Opera Browsers. Template Tags for Blogger, Movable Type and Wordpress platform are commented.
<script language="JavaScript1.2" type="text/javascript">
function CreateBookmarkLink() {

title = "Webpage Title";
// Blogger - Replace with <$BlogItemTitle$>
// MovableType - Replace with <$MTEntryTitle$>

url = "Webpage URL";
// Blogger - Replace with <$BlogItemPermalinkURL$>
// MovableType - Replace with <$MTEntryPermalink$>
// WordPress - <?php bloginfo('url'); ?>

if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title, url,"");
} else if( window.external ) { // IE Favorite
window.external.AddFavorite( url, title); }
else if(window.opera && window.print) { // Opera Hotlist
return true; }

if (window.external) {
document.write('<a href =
"javascript:CreateBookmarkLink()");">Add to Favorites</a>');
} else if (window.sidebar) {
document.write('<a href =
"javascript:CreateBookmarkLink()");">Bookmark Page</a>');
} else if (window.opera && window.print) {
document.write('<a href =
"javascript:CreateBookmarkLink()");">Add Bookmark</a>');
If your audience are visiting the site from a different web browser or if javascript is not supported , the bookmark link is not displayed.
Next >
When a webpage requires registration


Lost Password?


Coming soon...