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!
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!