Strict doctype with one validation error?

I gave you a nice, simple example above of how to do this cleanly without inline code. Have you tried it? It’s a much better way to go.

ralph.m - yes - I appreciate your script and have saved it. But on this project I’m going to have 7 or 8 products per webpage - each with a pop-up window of unique dimensions. I need to be able to put the Width and Height of each pop-up window in the anchor tag and have the W and H passed to the Script. I DON"T know how to do this.

That’s why I’m asking if there is anything inherently wrong with the onclick="window.open… solution that appears to work, also. Thanks for responding.

Ah, I see. I’m not experienced with JS, but I thought I’d see if I could adapt the script above to handle this scenario. It seemed to work fine. I just added in two more links, but you could add any number. I’m sure you’ll see the pattern. I’ve just highlighted in red what I added for the last example:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
	
<meta http-equiv="content-type" content="text/html; charset=utf-8">

<title>Example</title>

<script type="text/JavaScript">
window.onload = function() {
  if (!document.getElementsByTagName) return false;
  var lnks = document.getElementsByTagName("a");
  for (var i=0; i<lnks.length; i++) {
    if (lnks[i].getAttribute("class") == "popup1") {
      lnks[i].onclick = function() {
        popUp1(this.getAttribute("href"));
        return false;
      }
    }

    if (lnks[i].getAttribute("class") == "popup2") {
      lnks[i].onclick = function() {
        popUp2(this.getAttribute("href"));
        return false;
      }
    }

   [COLOR="Red"] if (lnks[i].getAttribute("class") == "popup3") {
      lnks[i].onclick = function() {
        popUp3(this.getAttribute("href"));
        return false;
      }
    }[/COLOR]

  }
}

function popUp1(winURL) {
  window.open(winURL,"popup1","width=618,height=618");
}

function popUp2(winURL) {
window.open(winURL,"popup2","width=800,height=900");
}

[COLOR="Red"]function popUp3(winURL) {
window.open(winURL,"popup3","width=200,height=300");
}[/COLOR]

</script>
</head>
<body>
<p><a href="page1.html" class="popup1">Page 1</a></p>
<p><a href="page2.html" class="popup2">Page 2</a></p>
[COLOR="Red"]<p><a href="page3.html" class="popup3">Page 3</a></p>[/COLOR]
</body>
</html>

That would work if there’s a limited number of different dimensions. But if there’s a lot of variations it will get bloated rather quickly.

I would make the links something like

<a href="page.html?wdth=600&amp;hght=450" class="popup">Page</a>

If javascript isn’t enabled the GET variables won’t get used, but no harm done.

Then instead of passing the href value directly to the popUp function, assign it to a variable. Use split() to separate the filename from the GET variables. Use match() to get the GET variable values. Then pass the parsed out values to the popUp function.

Thanks for everyone’s help.