[thelist] Basic JavaScript Help?

James Aylard webmaster at equilon-mrc.com
Wed Sep 26 10:00:50 CDT 2001


Richard and darren,

    darren's approach is an excellent one for a few of very good reasons:

1) it will work in a browser without javascript enabled
2) it allows shift-clickers (like me) to open the window by shift-clicking
(sans annoying blank window with javascript string in the address bar)
3) it passes on the url via this.href, which avoids the possibility of a
typo

    Additionally, you could pass the target value to your function if there
is a need to open content in different windows:

<script language="JavaScript">
  <!--
    function openWin(vUrl,vTarget)
    {
      n = open(vUrl,vTarget,'width=450,height=450,scrollable,resizable');
    }
  // -->
</script>

<a href="your url here" target="_blank"
  onclick="openWin(this.href, this.target);
  return false;">explanation</a>

    This applies the benefits of 1), 2), and 3) above to the target
attribute, as well (hats off to jeff for repeating this until it finally
stuck with me).

James Aylard





More information about the thelist mailing list