Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    bookmark javascript

    Hi

    I'm having a problem adapting (and calling) a create book map javascript within a html hot-spot link.

    The main script is:

    <script language="JavaScript">
    <!--
    var bookmarkurl="put the url that you want bookmarked here"
    var bookmarktitle="put the title that you want for the url here"

    function addbookmark(){
    if (document.all)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)
    }
    -->
    </script>


    The script element within the main code is:

    <a href="javascript:addbookmark()">bookmark our site</a>



    the hot spot link HTML is:

    <area shape="rect" coords="439,23,620,45" href="#" target="_self" title="Bookmark This Page" alt="Bookmark This Page" >



    Any ideas on how I adapt javascript within the hotspot HTML above?

    Thanks

    Dirk

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,616
    Thanks
    0
    Thanked 645 Times in 635 Posts
    1. Change:

    if (document.all)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)

    to

    if (window.external)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)

    since the code you are trying to run only works on some of the browsers that support document.all

    2. replace:

    href="javascript:addbookmark()

    with

    onclick="addBookmark();


    You can add that to whatever you want to apply it to including the <area>
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •