Link to home
Start Free TrialLog in
Avatar of nedwob
nedwob

asked on

Put an 'Add to Favorites' button on a Page

I assume that javascript is the language to do this.

I want to place a button or link on a page that will adde the page URL to the 'Favorites' listings.

I can't find anything in any books I have and a web search didn't come up with anything.

Can anyone please help?

thanks

nedwob
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


<a href="javascript:addbookmark()">Bookmark this site!</a>

Fritz the Blank
ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jeffrocks
jeffrocks

Or another way...

<A HREF="javascript:window.external.AddFavorite('http://www.mysite.com/anotherdir/thispage.html', 'Title of the bookmark')">Add this page to your favorites!</A>

Actually, that is pretty much the same way--both use:


window.external.AddFavorite(bookmarkurl,bookmarktitle)


Fritz the Blank
Here is another Javasript code.  Add to favourites text is displayed in explorer, but if the user is using Netscape then they are prompted to press ctrl-D.

Just paste the code wherever you want it to appear.


<SCRIPT LANGUAGE="JavaScript">
<!--
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {

var url="http://www.yoursite.com";
var title="Your site description";

document.write('<A HREF="javascript:window.external.AddFavorite(url,title);" ');
document.write('onMouseOver=" window.status=');
document.write("'Add our site to your favorites!'; return true ");
document.write('"onMouseOut=" window.status=');
document.write("' '; return true ");
document.write('">Add our site to your favorites!</a>');
}
else {
var msg = "Don't forget to bookmark us!";
if(navigator.appName == "Netscape") msg += "  (CTRL-D)";
document.write(msg);
}

// -->
</script>
 <script language="JavaScript">
 
<!-- Begin
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
 
var url="http://youraddress.com";
var title="Your Site Title";
 
document.write('<A HREF="javascript:window.ext');
document.write('ernal.AddFavorite(url,title);" ');
document.write('onMouseOver=" window.status=');
document.write("'Bookmark Us!'; return true ");
document.write('"onMouseOut=" window.status=');
document.write("' '; return true ");
document.write('">Bookmark Us!</a>');
}
else {
var msg = "Bookmark Us!";
if(navigator.appName == "Netscape") msg += "  (Please Bookmark Us Now Ctrl D)";
document.write(msg);
}
 
// End -->
</script>
Avatar of nedwob

ASKER

Thanks to all for the quick replies. I will look at the suggestions, and come back in a few days to award the points

nedwob
Avatar of nedwob

ASKER

Thanks to all for the comments - I have tried the suggestion from 'fritz the blank' at the URL http://www.dynamicdrive.com/dynamicindex9/addbook.htm. It works fine. As fritz made the most comments he gets the points.

nedwob
nedwob,

Glad to have helped. Any reason for the B? Is there anything else that you needed?

Fritz the Blank
Avatar of nedwob

ASKER

hi fritz the blank

No - I meant to hit A, but finger trouble caused me to hit the B I guess!

No other problems at present

nedwob
Okay, I'll drop a note to community support requesting a change.

Fritz the Blank
Avatar of nedwob

ASKER

Yes - please do - your answers and links certainly merit an A.

nedwob
Thanks!!!

Fritz the Blank