Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2008
    Posts
    33
    Plugin Contributions
    0

    Default What's wrong with my javascript?

    my page is: http://www.akwdesigns.com

    I have at the top of every page a link called "Bookmark This Page". It calls a javascript function which you can see if you view the sourcecode. I created a jscript_bkmrk.js file and put it in my includes/templates/mytemplate/jscript/ folder and I called it:

    jscript_bkmrk.js

    Code:
    <script language="javascript" type="text/javascript">
    function bookmarkMe(myUrl, myTitle)
    {
            if(window.sidebar)
            {
                   //******************************//
                   // Firefox is used
                   // We can just prompt the user
                   // to add a regular bookmark...
                    //******************************//
    
                   alert('Please press CTRL+D to bookmark this page!');
    
                   //******************************//
                   // ... or we can add a 'sidebar' bookmark.
                   // To do it, use the line below,
                   // instead of the line above:
                   //******************************//
    
                   // window.sidebar.addPanel(myTitle, myUrl, '');
    
                   //******************************//
                   // In the second case, you can
                   // give the visitor additional information.
                   // to do it, uncomment the lines below
                   //******************************//
    
                   // var msg = "Firefox has just added the bookmark ";
                   // msg += "that will open in the sidebar by default.\n";
                   // msg += "If you want it to open in the main window instead, ";
                   // msg += "please go to Bookmarks, right-click the recently ";
                   // msg += "added bookmark, choose 'Properties' and uncheck the ";
                   // msg += "'load this bookmark in the sidebar' option.\n\n";
                   // msg += "Sorry, this in unavoidable with Firefox so far.";
                   // alert(msg);
            }
            else if(window.opera && window.print)
            {
                   //******************************//
                   // Opera is used
                   //******************************//
    
                   var bkmark = document.createElement('a');
                   bkmark.setAttribute('rel','sidebar');
                   bkmark.setAttribute('href', myUrl);
                   bkmark.setAttribute('title', myTitle);
                   bkmark.click();
            }
            else if(document.all)
            {
                   //******************************//
                   // Most probably IE, but even if it's not,
                   // we don't want an error to pop up
                   // so we use the try-catch structure
                   //******************************//
    
                   try
                   {
                           window.external.AddFavorite(myUrl, myTitle);
                   }
                   catch(e)
                   {
                           //******************************//
                           // oops! not IE. Prompt user for action.
                           //******************************//
    
                           var msg = "Sorry, your browser doesn't allow scripts ";
                           msg += "to add bookmarks.\n";
                           msg += "Please use your browser's keyboard shortcut ";
                           msg += "(most commonly CTRL+D) to add a bookmark.";
                           alert(msg);
                   }
            }
    }
    </script>
    If you view the source you can see it's called correctly.

    And the link seems to be ok too:

    Code:
    <a href="javascript:bookmarkMe('http://www.akwdesigns.com','AKW Designs, Custom Jewelry Creations')">Bookmark This Page</a>
    But for some reason the link does nothing in IE or Firefox (haven't been able to test Opera or Safari yet).

    I do see an "object expected" error in the bottom left of IE but that's not very descriptive.

    Thanks for the help.

  2. #2
    Join Date
    Sep 2007
    Location
    Somewhere in Southern Cal
    Posts
    330
    Plugin Contributions
    0

    Default Re: What's wrong with my javascript?

    That should work for some reason it's not calling the javasript.
    It might be looking for a path....
    If you put the script inside your
    <a href="javascript:bookmarkMe('http://www.akwdesigns.com','AKW Designs, Custom Jewelry Creations')">Bookmark This Page</a>
    it works.
    You might have to place the javascript within your zen home page.

    nomad

  3. #3
    Join Date
    Jan 2008
    Posts
    33
    Plugin Contributions
    0

    Default Re: What's wrong with my javascript?

    what do you mean "within your zen home page"? and how do I put it inside the <A> tag?

    thanks

  4. #4
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: What's wrong with my javascript?

    If you put the file inside js file, you DONT put the content between the script tag

    Remove
    <script language="javascript" type="text/javascript">

    and
    </script>
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  5. #5
    Join Date
    Sep 2007
    Location
    Somewhere in Southern Cal
    Posts
    330
    Plugin Contributions
    0

    Default Re: What's wrong with my javascript?

    That's why there was an error on line one for. I will have to remember that one next time. Thanks Yellow1912

    nomad

  6. #6
    Join Date
    Sep 2007
    Location
    Somewhere in Southern Cal
    Posts
    330
    Plugin Contributions
    0

    Default Re: What's wrong with my javascript?

    Just to let you know the javascript would have gone inside the header section, and not the body section or inside the <A> tag

    nomad

  7. #7
    Join Date
    Jan 2008
    Posts
    33
    Plugin Contributions
    0

    Default Re: What's wrong with my javascript?

    Thanks. I figured that out right before your post. Now it works in IE, but in firefox and safari it doesn't. For now I just added the text "(CTRL+D)" to the link, but eventually i want the link to work across these three browsers.

    any ideas?

  8. #8
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: What's wrong with my javascript?

    The script is working fine now, the reason it does not work on FF is probably because the script was not written to be cross-broswer compatible,
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

 

 

Similar Threads

  1. What's wrong with iframes?
    By brushwoodnursery in forum General Questions
    Replies: 2
    Last Post: 8 Nov 2008, 06:12 PM
  2. What is wrong with my code?
    By mikenandrea in forum General Questions
    Replies: 4
    Last Post: 9 Jan 2008, 01:46 AM
  3. AH! What's Wrong With My Page?
    By khopek in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 21 Aug 2006, 08:09 PM
  4. What is wrong with my site?????
    By blumpie in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 17 Aug 2006, 07:57 PM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR