Results 1 to 5 of 5

Thread: How to bookmark current page, not just your domain?

  1. #1
    Join Date
    Oct 2005
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to bookmark current page, not just your domain?

    Im using the bookmark script:

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

    I got it working, but you have to specify the page in advance, so I chose www.dynamicdrive.com. But I want people to be able to bookmark the current page: e.g. http://www.dynamicdrive.com/forums/newthread.php.

    Is there a way to let the script read the url you're at?

    My link code:

    <a href="javascript:bookmarksite('dynamic drive', 'http://www.dynamicdrive.com')">bookmark</a>

    Thanks for reading this

  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

    HTML Code:
    <a href="javascript:bookmarksite('dynamic drive', 'http://www.dynamicdrive.com/forums/newthread.php')">bookmark</a>
    Or, to bookmark the actual page you are on:

    HTML Code:
    <a href="javascript:bookmarksite(document.title, window.location.href)">bookmark this page</a>
    - John
    ________________________

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

  3. #3
    Join Date
    Oct 2005
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for answering everybody's questions John.

    I think you got the right idea with your your 2nd snippet of code, but for some reason I cant get it to work...

    I'll just post my html file:

    Code:
    <html>
    
    	<head>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    		<title>Untitled Page</title>
    <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
    ***********************************************/
    function bookmarksite(title, url){
    if (document.all)
    window.external.AddFavorite(url, title);
    else if (window.sidebar)
    window.sidebar.addPanel(title, url, "")
    }
    </script>
    	</head>
    	<body bgcolor="#ffffff">
    		<p><a href="javascript: bookmarksite(document.title, window.location.href)">bookmark this page</a></p>
    	</body>
    </html>

    Here's the error Opera gives (doesnt work in IE either):

    Code:
    Untitled Page
    http://www..../untitled.html
    Javascript URL thread: "javascript: bookmarksite(document.title, window.location.href)"
    Error:
    name: TypeError
    message: Statement on line 9: Could not convert undefined or null to object
    Backtrace:
      Line 9 of inline#1 script in http://www...../untitled.html
        window.external.AddFavorite(url, title);
      Line 1 of unknown script 
        bookmarksite(document.title, window.location.href);
    Any clue what the problem is?

  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

    Well, this script (at least with my modifications) won't work locally, the page needs to be live. Also, the script is not rated for Opera to begin with so, forget about that browser when testing. I copied your code, published the page, clicked on the link, and got a nice bookmark for my trouble.
    - John
    ________________________

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

  5. #5
    Join Date
    Oct 2005
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Not surprisingly, you were right!

    While making the test page I tested it locally in IE and it didnt work. Then I got the smart idea to test it online but I forgot the script didnt work in Opera!

    Your alteration really improves that script. Cant DD post your code as well?
    Downside is that your signature wouldnt be true anymore

    Thanks again.

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
  •