Results 1 to 6 of 6

Thread: Help with 'Bookmark this page' script.

  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with 'Bookmark this page' script.

    1) Script Title: Bookmark Site script

    2) http://dynamicdrive.com/dynamicindex9/addbook.htm

    3) Hello, could I get some help with customizing this script so that it bookmarks only the page that its transferred to ? For example, I run a weather site and would like my visitors to have the option to 'bookmark this forecast' after entering their zipcode. (thus, the url's are different all the time)

    So far all I could see is that we must specify the url in this script. Anyway to be able to specifically bookmark the page that they land on ?

    any help is much appreciated.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Well, the function of the script can be passed in a different set of bookmark title and URL to bookmark that page:

    Code:
    bookmarksite('Dynamic Drive', 'http://cnn.com')
    Instead of the above, you can enter a set of variables as the parameters instead:

    Code:
    <a href="javascript:bookmarksite(booktitle, bookurl)">Bookmark this site!</a>
    in which the actual bookmark page's title and URL is defined inside these two variables:

    Code:
    <script>
    var booktitle="Dynamic Drive"
    var bookurl="http://www.dynamicdrive.com"
    </script>
    Pending some action of your choice, you'd modify the values of these two JavaScript variables, and the bookmark will change accordingly when the bookmark script is called. If you need more help let us know.
    DD Admin

  3. #3
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    arghh, sorry I forgot about this thread..

    I finally got around to messing around with this & got it to work with var's ddadmin mentioned.

    works fine in IE.

    but it looks like the new version of FireFox doesn't mix well with this script.

    When you click on "Book Dynamic Drive" from your own page (with FireFox) -

    http://dynamicdrive.com/dynamicindex9/addbook.htm

    after bookmarking... click on the bookmark... it opens the site within the small bookmark column...instead of the main window to its right like it's suppose to.


  4. #4
    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

    That's always been a limitation of Firefox. The only javascript bookmarks it accepts are those kind, AKA sidebar. They can always be converted by the user to normal by unchecking the open in sidebar checkbox.
    - John
    ________________________

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

  5. #5
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    They can always be converted by the user to normal by unchecking the open in sidebar checkbox.
    This is an option in FireFox ? (I can't seem to locate it)

    last question after the above :

    I've got the var bookmark url looking somewhat similar to this -

    var bookurl="%%fulljurl%%%%place%%.html"

    the place variable specifically outputs the current town. And it works fine if the town is 1 word. But occasionally towns have more than 1 word. (example, new york city , mount pocono , etc )

    my current program only recognizes the + symbol as the space identifier. but when adding to bookmark, it outputs spaces as %20 , which in turn makes the URL a dead link.

    think there's an ez fix for this ? Any help is greatly appreciated.

  6. #6
    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

    In Firefox make a bookmark using this script. Then find it in the Bookmarks menu. Right click on it, choose properties. Uncheck the checkbox labeled:

    Load this bookmark in the sidebar

    As to your other question, %20 is usually a valid stand in for a space character in a URL. I'm uncertain of your overall setup or of the amount of control we can exert over the script.

    The two obvious choices would be:

    1. Get it to stop using %20

    2. Use a different delimiter in the place name something other than space, ie: new_york_city


    If it's not too much trouble to implement, #2 would be more certain. However, %20 is simply the escaped version of space for URL's. We could try (addition highlighted):

    Code:
    <script type="text/javascript">
    
    /***********************************************
    * Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    /* Modified to support Opera */
    function bookmarksite(title,url){
    url = unescape(url);
    if (window.sidebar) // firefox
    	window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print){ // opera
    	var elem = document.createElement('a');
    	elem.setAttribute('href',url);
    	elem.setAttribute('title',title);
    	elem.setAttribute('rel','sidebar');
    	elem.click();
    } 
    else if(document.all)// ie
    	window.external.AddFavorite(url, title);
    }
    </script>
    - John
    ________________________

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

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
  •