www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 09-24-2006, 03:17 AM
    irf2k irf2k is offline
    Registered User
     
    Join Date: Jul 2006
    Posts: 78
    adding a bookmark using JS

    i have written the following code to generate a bookmark for the current page:
    Code:
    function errorMsg()
    {
      alert("Your browser does not support this feature");
    }
    function addBookmark()
    {
      var urlValue = "http://www.trackerurl.com?url="+escape(window.location); 
      var titleValue = window.name;
      if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) { 
    	window.sidebar.addPanel(titleValue, urlValue,"");
      } else if ((typeof window.external == "object") && (typeof window.external.AddFavorite == "function")) { 
    	window.external.AddFavorite(urlValue, titleValue); 
      } else {
        errorMsg();
      }
    }
    my problem has three parts:
    1. The "titleValue = window.name;" does not seem to work correctly (what is the code to get the title of the current page?)
    2. "(typeof window.external == "object") && (typeof window.external.AddFavorite == "function")" does not seem to work in IE which is what it is aimed at...if i use "if (window.external) it works fine...why?
    3. Are there any other main browsers that I am not targeting with this code, and what should I do to add them?

    thanks
    Reply With Quote
      #2  
    Old 09-24-2006, 04:18 AM
    Fang's Avatar
    Fang Fang is offline
    Resistance is futile
     
    Join Date: Apr 2003
    Location: Netherlands
    Posts: 17,224
    1. document.title
    2. & 3. http://labnol.blogspot.com/2006/01/a...k-firefox.html
    __________________
    At least 98% of internet users' DNA is identical to that of chimpanzees
    Reply With Quote
      #3  
    Old 09-24-2006, 04:20 AM
    Kravvitz Kravvitz is offline
    CSS & JS/DOM Adept
     
    Join Date: Jul 2005
    Location: USA
    Posts: 3,913
    1) document.title is probably what you want.
    2) I've wondered that myself.
    3) Yes. Check out The Ultimate Add Bookmark Script.
    __________________
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions

    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

    Check out my blog.
    Reply With Quote
      #4  
    Old 09-24-2006, 02:33 PM
    irf2k irf2k is offline
    Registered User
     
    Join Date: Jul 2006
    Posts: 78
    @kravvitz
    The Ultimate Add Bookmark script seems little complex to me, since I'm not used to javascript...I like coding I can understand so I can play around with it if need be....
    but regarding the site "http://labnol.blogspot.com/2006/01/add-to-favorites-ie-bookmark-firefox.html" posted by Fang....
    how does this code work in Opera:
    else if(window.opera && window.print) { // Opera Hotlist
    return true; }

    I mean, as far as I can see, it is just returning true, so its not really doing anything...I haven't tested it, but even if it worked, I'd like to know HOW...
    thnx
    Reply With Quote
      #5  
    Old 09-24-2006, 03:10 PM
    Fang's Avatar
    Fang Fang is offline
    Resistance is futile
     
    Join Date: Apr 2003
    Location: Netherlands
    Posts: 17,224
    Works in IE, FF and Opera:
    Code:
    <a href="#" rel="sidebar" onclick="if(document.all && !window.opera){ window.external.AddFavorite(location.href, document.title);return false; }else{ this.title = document.title; }" title="bookmark this page">Bookmark This Page</a>
    __________________
    At least 98% of internet users' DNA is identical to that of chimpanzees
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:10 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.