Bookmark Page Link Tutorial

Made by: Nick

In this tutorial I will show you how to make a link to bookmark your URL. If your still not sure what I mean then visit our homepage and scroll to the bottom, see the big "Bookmark Us" link? Well that is what I am going to show you how to make in this tutorial.

I have tested this in Firefox 2 & 3, Internet Explorer 7 and Opera 9. It should work in other browsers and some previous versions of these browsers, I just don't have them to test it.

The Javascript Code

You need to place this in a file which we will name "bookmark.js":

function bookmarksite(title,url){
if (window.sidebar)
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print)
{var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all)
window.external.AddFavorite(url, title);
}

This code basicly sets a function called bookmarksite. This function is then called when the link which I will give you the code for later is clicked. The function then takes the information from the link code and makes the browser bookmark/add to favorites the url you have specified.

Adding the JavaScript to your HTML

After you make this file you need to add it to the section of the page(s) you want to add the bookmark link to, you can do this by placing this code there:

<script type="text/JavaScript" src="bookmark.js"></script>

The Link Code

After making the JavaScript file and adding it to the page(s) you want your bookmark link on, all you need to do is place this link in your HTML code wherever you like.

 <a href="javascript:bookmarksite('Free Div Layouts', 'http://www.freedivs.com/')" title="bookmark" id="bookmark-link">Bookmark Us</a>

Feed the Dragon MySpace Tutorials