Hi, I want to create a button(standard one- submit or clear type) on which when a user click for bookmarking the page. Having the button is important part. Regards
Put something like this within the head section of your HTML document, or better yet, skip the script tags and put it in an external file and link to it in the head section instead: <script language="JavaScript" type="Text/Javascript"> <!-- // var url = "http://www.webpelican.com/internet-programming-3/"; var pageName = "Client side programming"; function bookmark() { if (window.external) { window.external.AddFavorite(url, pageName) } else { alert("Sorry! Your browser doesn't support function. Use the bookmark option in your browser instead."); } } // --></script> Code (markup): And this somewhere in the body section of your HTML document: Button: <input type="button" name="Bookmark this page" onclick="bookmark()" /> or... Simple link: <a href="javascript:bookmark()">Click here to bookmark this page </a> (and of course change the URL to whatever URL you would like to bookmark )
Thanks..let me check it....and one more thing, as far as putting code in a file is concerned, how can I include that file ? should it be a .js file ?
<script src="/myExternalJavaScript.js" type="text/javascript"></script> should can be put at the end of the body(within the body's start and end tag) if it is important to the functionality of the script that all the document elements have loaded. Otherwise it can be put at the end of the head section. I'm by no means a guru in this area since I usually don't do much client side scripting. However, I have done some probably not to great JavaScript coding. The code is open to view and/or download. Below is one example. You can download the file at the bottom of the page. Then link to it as described above. When you tried that, there shouldn't be a problem doing your own scripts. DOM Properties, JavaScript Give it a try
here is code for bookmark <script Type="text/javascript"> /* Modified To support Opera */ function bookmark(title,url){ var sPath = window.location.pathname; var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); url =url+sPage; if (window.sidebar) // firefox window.sidebar.addPanel(title, url, ""); else if(window.opera && window.print){ // opera var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); } else if(document.all)// ie window.external.AddFavorite(url, title); } </script>
A detailed tutorial can be find from here. Boomark a Page Also add-this is a good-option that allows bookmarking, social sharing and much more.