Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Add to favorites script

  1. #1
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Add to favorites script

    I have an "Add this page to your favorites" script on my web site. It works fine in IE, but I can't get it to work in Firefox. If you click the link in Firefox, nothing happens. If I change the tab to IE, but still use Firefox, I get a runtime error message that says, "window.external is null or not an object." Here is the script I am using:

    <a href="javascript:window.external.AddFavorite('http://mysite.com','site description')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('b11','','images/buttons/addfav_2.gif',0)"><img src="images/buttons/addfav_1.gif" name="b11" width="139" height="28" border="0"></a>

    I have tried using the "bookmark this page" on other sites and can't get theirs to work in Firefox either.

    Does anyone have a solution?

    ckirk

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You cannot bookmark in FF (and certain similar NS) without the sidebar. This produces a slightly different sort of bookmark that can later be converted to an ordinary bookmark by the user if he or she chooses to do so and knows how. No browsers other than FF (and certain similar NS) and IE can do any sort of javascript driven bookmarks, at least as far as I know. Did you try this script from the DD library:

    http://www.dynamicdrive.com/dynamicindex9/addbook.htm
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Add to Favorites script

    Thanks, John. That script provided a workable solution. It works in FF and it works in IE. The only thing you can't do is use it when using the FF extension to view a page in IE and there isn't any reason I can think of why anyone would need to do that.

    Thanks again,

    ckirk

  4. #4
    Join Date
    Jun 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    You cannot bookmark in FF (and certain similar NS) without the sidebar. This produces a slightly different sort of bookmark that can later be converted to an ordinary bookmark by the user if he or she chooses to do so and knows how. No browsers other than FF (and certain similar NS) and IE can do any sort of javascript driven bookmarks, at least as far as I know. Did you try this script from the DD library:

    http://www.dynamicdrive.com/dynamicindex9/addbook.htm
    Hi, do you know how to do the code on that link you kindly suggested above, but with the js code in a separate page please ? I've been trying, but can't seem to be able to do it.

    Any help appreciated.

    Saz.

  5. #5
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there Saz,

    and a warm welcome to these forums.

    Does this help...
    some_page.html
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>bookmark dynamicdrive forums</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript" src="bookmark.js"></script>
    
    </head>
    <body>
    
    <ul>
    <li><a class="bookmark" href="http://www.dynamicdrive.com/forums/" title="dynamicdrive forums">dynamicdrive forums</a></li>
    <li><a  href="http://www.w3schools.com/" title="w3schools">w3schools</a></li>
    </ul>
    
    </body>
    </html>
    boomark.js
    Code:
    window.onload=function() {
       anc=document.getElementsByTagName('a');
    for(c=0;c<anc.length;c++) {
    if(anc[c].className=='bookmark') {
       anc[c].onclick=function() {
    if(document.all) {
       window.external.AddFavorite(this.href,this.title);
     }
    else {
    if(window.sidebar) {
       window.sidebar.addPanel(this.title,this.href,'');
      
          }
         }
        }
       }
      }
     }
    coothead

  6. #6
    Join Date
    Jun 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Many thanks for the help Coothead and thanks also for the warm welcome

    One thing, which one is better please ?

    <script language="JavaScript" type="text/javascript" src="bookmark.js"></script>

    <script type="text/javascript" src="bookmark.js"></script>

    Saz.

  7. #7
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there Saz,

    language="JavaScript" is deprecated and should not be used.

    coothead

  8. #8
    Join Date
    Jun 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the quick help on this Coothead - it's appreciated.

    Just tried the code you kindly suggested, but when clicking on the link, it doesn't add the site to the favorites in either IE or FF ;-(

    http://www.010805.com/favorites/

    Saz.

  9. #9
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there Saz,
    ...but when clicking on the link, it doesn't add the site to the favorites in either IE or FF
    the reason for this is that, you have not placed bookmark.js in the same directory as your links page.
    At the moment it is at...
    ...whereas your links page is at...
    Let them get together and it should, hopefully, produce a satisfactory union.

    coothead

  10. #10
    Join Date
    Jun 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Many thanks Coothead - ya don't fancy a job as my guardian angel do you ?

    Ok, we're now a step nearer - but when clicking the link, it *does* bring up the add to favs box, *but* it also goes to the page in the link ;-(

    http://www.010805.com/favorites/

    Also, are you able to apply a hover class to the links at all please ?

    Saz.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •