471,618 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,618 software developers and data experts.

Complete beginners question on adding to favorites...

Hi all I a complete beginner when it come to using HTML code so please help me out!

All I want to do is create a link in my document that will add my page to the browers' favorites list. What I have created is a Roll-Over image in Dreamweaver 8, which is placed is a layout table. I know that the code to put the page into the favorites folder is [HTML]onclick='window.external.AddFavorite(location.href ,document.title)[/HTML] however I don't know where to fit it into my code... Here's what I have...

[HTML] <td height="28" colspan="2" valign="top"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('AddtoFav','','images/frontpageALT_04.gif',1)"><img src="images/frontpage_04.gif" name="AddtoFav" width="98" height="28" border="0" id="AddtoFav" /></a><a onmouseover="MM_swapImage('AddtoFav','','images/frontpageALT_04.gif',1)" onmouseout="MM_swapImgRestore()"></a></td>
<td colspan="5" valign="top"><img src="images/frontpage_05.gif" width="413" height="28" /></td>[/HTML]

Thanks in advance for your help!

EDIT: Typo fixed
Sep 4 '07 #1
2 1342
173 Expert 100+
Hi Cob,

Welcome to TSDN...

To add the script functionality you would just put what you have within the anchor element that you want it to be linked to:

<a href="..." onclick="javascript"></a>
Secondly there is not standard way to add bookmarks, the script that you have is IE specific so if a user of any other browser clicked the link then script would not execute. A javascript function that works on IE and FireFox (sorry, haven't found the methods for other browsers at the moment) is:

Expand|Select|Wrap|Line Numbers
  1. function bookmark(){
  2.     var $title=document.title;
  3.     var $url=self.location.href;
  5.     if (window.sidebar){
  6.       window.sidebar.addPanel($title, $url,"");
  7.     } else if( document.all ){
  8.       window.external.AddFavorite( $url, $title);
  9.     } else {
  10.       alert("Sorry, your browser does not support this function. \n Please add the bookmark manually.");
  11.     }
  12.     return false;
  13. }
The onclick attribute of your anchor would then call this function:

<a href="#" onclick="return bookmark();"></a>
Sep 4 '07 #2
Thank you for this, it works perfectly and I certainly had no chance of getting there myself!
Sep 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by shank | last post: by
9 posts views Thread by Dennis Ruppert | last post: by
2 posts views Thread by Tom McL. | last post: by
5 posts views Thread by draken | last post: by
5 posts views Thread by andrewq2 | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.