[thelist] Problems using 'location' with Navigator

Andrew Clover and at doxdesk.com
Sat Apr 13 08:20:01 CDT 2002


Peter Small wrote:

> I've driven myself mad trying to get a set of scripts to work with all
> browsers.

It's just a typo. You've put:

  <a hre="..." onclick="...">

and copied it onto every link. It should of course be <a href>. Netscape 4
will only fire onclick events for things it thinks you can actually click
on. And <a> with href is not a link, so isn't clickable in N4.

Of course the correct way of doing it, that doesn't break non-JS browsers
and functions like 'open in new window' is to use a standard URL in the
href (javascript: URLs should not be used ever), and have the onclick code
return false so that the link is not followed in the original window.
Example code:

  <script type="text/javascript">
    function popup(link) {
      window.open(link.href, '', '...options...');
      return false;
    }
  </script>
  <a href="newpage.html" onclick="return popup(this);"><img blah></a>

--
Andrew Clover
mailto:and at doxdesk.com
http://and.doxdesk.com/



More information about the thelist mailing list