Article directory - Cheap airsoft - Record Internet Radio with Tags - Free Credit Repair - Myspace Friend Train

PDA

View Full Version : javascript bookmark / favorites issue.


deluxmilkman
Dec 14th 2007, 10:31 am
I'm trying to make a book mark button the following is what I have.
It shows the alert, but bookmark nothing.
(I'm using Mac.)



function bookmark(title, url){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {

window.external.AddFavorite(url,title);
alert("IE: bookmarked");
}
else if(navigator.appName == "Netscape"){
alert("NETSCAPE: NOT SUPPORTED");
}else{
alert("NOT SUPPORTED");
}
}


<a href="javascript:bookmark('My title','My url');">Click to Bookmark</a>

When I use the following in function, nothing happens.


if (window.sidebar) {
window.sidebar.addPanel(title, url);
} else if( window.external ) {
window.external.AddFavorite( url, title);
}

Can you help me?

KatieK
Dec 16th 2007, 9:21 pm
It seems to me that the reason that you're not getting the page bookmarked is that you're using a Mac. (What browser are you using?)

The AddFavorite function is in IE-only (http://www.javascripter.net/faq/bookmar4.htm) - hence the "if Microsoft Internet Explorer" code. You getting the alert, but no bookmark is the correct behavior.

DatR
Dec 17th 2007, 9:11 pm
try this script i use on my one site:


function bookmark(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

temp2
Dec 18th 2007, 5:52 pm
thank you for good tip