Results 1 to 2 of 2

Thread: Possible to "bookmark this.." in firefox with the "self.location.."

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

    Default Possible to "bookmark this.." in firefox with the "self.location.."

    Heres what I'm using that won't work:

    header-

    <script type="text/javascript">

    function bookmarksite(title, url){
    if (document.all)
    window.external.AddFavorite(url, title);
    else if (window.sidebar)
    window.sidebar.addPanel(title, url, "")
    }

    </script>

    url-

    <a href="javascript:bookmarksite('document.title', 'self.location.href')">Bookmark this site!</a>

    Nothing happens when I click it. It works when you put in a url and title, but not with that^

    Anyone ever solve 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

    Appears to be a classic case of string vs. variable. When you go:

    Code:
    <a href="javascript:bookmarksite('Home Page', 'http://www.domain.com/index.html')">
    You are passing two string literals to the function but, when you go:

    Code:
    <a href="javascript:bookmarksite('document.title', 'self.location.href')">
    You are trying to pass two variables. By quoting them, you turn them back into string literals (ones that make no sense to the function, or more precisely, the browsers the function is targeting). The proper method (assuming these variables have the expected values) would be:

    Code:
    <a href="javascript:bookmarksite(document.title, self.location.href)">
    without quotes. That way, they will be treated as variables and (if properly defined before this link is clicked) resolved to their assigned values by the function.
    - 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
  •