DIYGUY
03-13-2009, 02:43 PM
I am brand new here and to JS ~ if this is the wrong forum for this type of post I will gladly take it elsewhere!
I would like to be able to have a user capture the page they are viewing quickly and efficiently into a bookmark. Bouncing around the net I found several different scripts where you could hardcode a bookmark - for example, a start page. What I want a user to do is something like this, navigate down to: http://www.example.com/firstpage/secondpage/thirdpage.htm and let the reader place that URL into their bookmarks, by clicking on an image perhaps.
This is my current approach (which is not working and thus why I am here). I have a Jscript dir sitting under my Code dir. In that Jscript dir I have the following script: "bookmark.js" and it contains this code:
function addbookmark() {
title = "document.title";
url = "window.location.href";
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
window.external.AddFavorite( url, title); }
}
if (window.external) {
document.write('<a href =
"javascript:addbookmark()");">Add to Favorites</a>');
} else if (window.sidebar) {
document.write('<a href =
"javascript:addbookmark()");">Bookmark Page</a>');
}
In the head section of pages using this function:
<script language="JavaScript" type="text/javascript" src="Jscript/bookmark.js"></script>
This is the XHTML in the actual pages that use this function:
<a href="javascript:addbookmark(document.title, window.location.href)"><img src="images/bookmark.gif" /></a>
All of the above is pretty much cobbled together from bits and pieces I found. I don't pretend to be a programmer, nor JS literate. Any pointers you could offer me to make this work are muchly appreciated ...
I would like to be able to have a user capture the page they are viewing quickly and efficiently into a bookmark. Bouncing around the net I found several different scripts where you could hardcode a bookmark - for example, a start page. What I want a user to do is something like this, navigate down to: http://www.example.com/firstpage/secondpage/thirdpage.htm and let the reader place that URL into their bookmarks, by clicking on an image perhaps.
This is my current approach (which is not working and thus why I am here). I have a Jscript dir sitting under my Code dir. In that Jscript dir I have the following script: "bookmark.js" and it contains this code:
function addbookmark() {
title = "document.title";
url = "window.location.href";
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
window.external.AddFavorite( url, title); }
}
if (window.external) {
document.write('<a href =
"javascript:addbookmark()");">Add to Favorites</a>');
} else if (window.sidebar) {
document.write('<a href =
"javascript:addbookmark()");">Bookmark Page</a>');
}
In the head section of pages using this function:
<script language="JavaScript" type="text/javascript" src="Jscript/bookmark.js"></script>
This is the XHTML in the actual pages that use this function:
<a href="javascript:addbookmark(document.title, window.location.href)"><img src="images/bookmark.gif" /></a>
All of the above is pretty much cobbled together from bits and pieces I found. I don't pretend to be a programmer, nor JS literate. Any pointers you could offer me to make this work are muchly appreciated ...