Debt Consolidation - Wordpress Themes - Wordpress Themes - Health 2007 - Free Animated Greetings

PDA

View Full Version : Bookmark link that works for ALL 3 main browsers


joshm
Mar 27th 2006, 10:05 pm
I have been looking for some javascript that allows a bookmark link to work on all 3 browsers: IE, Firefox, Opera. I am using a button for the bookmark function. I know there is some js code that works with a <a href> link but am curious as to whether I can make this work on all browsers using a button.

I have the below code in a javascript file named /bm.js:

function bookmark(url,title){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
window.external.AddFavorite(url,title);
} else if (navigator.appName == "Netscape") {
window.sidebar.addPanel(title,url,"");
} else {
alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
}
}

In the <head> tag of my page I have:
<script type="text/javascript" src="/js/bm.js"></script>

In the body of my page I have:
<form action="#">
<input type="button" value="Bookmark Us" onclick="bookmark('http://wwwmydomainname.com','MyDomainName')">
</form>

Now, it works fine in IE and Firefox but upon clicking on the bookmark button in Opera, it does not even display the alert message as expected. I am using Opera V8.53. It doesn't like this script at all. Can there be a way for the bookmark button to function properly in Opera and allow people to add to favorites? Any help much appreciated!

exam
Mar 31st 2006, 11:31 pm
Is your Opera identifying itself as Opera or as IE?

joshm
Apr 1st 2006, 1:59 am
Is your Opera identifying itself as Opera or as IE?

How can I find out this information?

brian394
Jun 16th 2006, 12:35 am
How can I find out this information?
Go into your Tools menu and then select Quick Preferences to see what Opera is identifying itself as.
You can also press F12 at any time to bring up this menu.

Speaking of bookmark scripts, here is a "Bookmark for all browsers" script that I wrote a while ago. Seems to work correctly in IE, FireFox, and Opera. Let me know what you think...

Put this in your Javascript...

function bookmarkPage(t) {
if (window.external) { window.external.AddFavorite(location.href, document.title); }
else if (window.sidebar) { window.sidebar.addPanel(document.title, location.href, ""); }
else if (window.opera) { if (t.rel == "sidebar") { t.href = location.href; t.title = document.title; } else { alert('To bookmark this page, click "OK" below \nand then press CTRL-T on your keyboard.'); } }
else { alert('To bookmark this page, click "OK" below \nand then press CTRL-D on your keyboard.\n(Macintosh users press Command-D.)'); }
}

And put this in your (X)HTML...

<a href="javascript:void(0)" onclick="bookmarkPage(this)" rel="sidebar">Bookmark This Site</a>

Remember to add the rel="sidebar" attribute to your bookmark link for it to work in Opera.