Netscape doesn't work with href:javascript


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Netscape doesn't work with href:javascript

  1. #1
    John Morrison Guest

    Netscape doesn't work with href:javascript


    I am working with a ASP document that uses hyperlinks in manner similar to:

    <A HREF="javascript:SomeFunction()">button gif</A>

    IE5 and the Opera Browser have no problem executing this code. But Netscape
    4.75 ignores it for some reason. However, if I change it to an inline javascript
    command like:

    <A HREF="javascript:alert('Hi There')">button gif</A>

    Netscape will execute it just fine. Is this a bug ? Or a design feature
    ? Anyone else run into this?

    This is driving me CRAZY !!!

    John Morrison


  2. #2
    John Morrison Guest

    Re: Netscape doesn't work with href:javascript


    Ok, I think I'm narrowing this down some. I suspect that this problem is
    somehow related to
    the DOM, because the ASP code that I'm working with uses a lot of sections
    and layers. My
    gut feeling is that Netscape Communicator is enforcing a stricter interpretation
    of the DOM
    than IE5 and Opera.

    The reason I think so is that even when I replace the function name after
    the href, i.e.

    <a href="javascript:functionname">

    with

    <a href="javascript:document.formname.submit()">

    It still doesn't work in Netscape, but does in the other browsers. It's
    like Netscape is not able to
    see the scripts or forms from inside the href element.

    I've tried prefacing the function name with object names such as "document",
    "window", and
    so forth, but that doesn't work either.

    Would scripts be considered children of the document, the window, the layer
    they are in . . . what?

    I am going slowly insane trying to figure this out.

    John Morrison

  3. #3
    Frederiek Guest

    Re: Netscape doesn't work with href:javascript


    The following sample works perfectly well in NS:

    <html>
    <head>
    <title>Test</title>
    <script type="text/javascript" language="Javascript">
    <!--
    function something() {
    document.myForm.name.value = "you";
    alert('this works');
    }
    //-->
    </script>
    </head>
    <body>
    <a href="javascript:something()">click</a><br>
    <form name="myForm">
    <input name="name" value="me">
    </form>
    </body>
    </html>

    There must be something wrong elsewhere or in the script itself.
    Does the NS Javascript Console return any errors?

    Can you post the URL of a sample page?

    BTW, I don't know anything about ASP, I develop on Mac (current browser:
    NS 4.75).

    cya
    Frederiek


  4. #4
    Hiroshimator Guest

    Re: Netscape doesn't work with href:javascript


    "John Morrison" <jdm1intx@home.com> wrote:
    >
    >I am working with a ASP document that uses hyperlinks in manner similar

    to:
    >
    > <A HREF="javascript:SomeFunction()">button gif</A>
    >
    >IE5 and the Opera Browser have no problem executing this code. But Netscape
    >4.75 ignores it for some reason. However, if I change it to an inline javascript
    >command like:
    >
    > <A HREF="javascript:alert('Hi There')">button gif</A>
    >
    >Netscape will execute it just fine. Is this a bug ? Or a design feature
    >? Anyone else run into this?
    >
    >This is driving me CRAZY !!!
    >
    >John Morrison
    >


    add a

    return false;

    after your function. I encoutered the same problems some time ago, this solved
    it. Has something to do with NS trying to execute the link.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center