Forum Moderators: open
The page is coded in HTML 4.01 strict.
So far, I have:
<tr>
<td>cloth name</td>
<td><img src="images/cloths/cloth-name.jpg" alt="image of textured, cloth" width="100" height="40"></td>
<td><a href="images/cloths/large-cloth-name.jpg" target="newWindow" onclick="window.open(this.href, this.target); return false">Large image [new window]</a></td>
</tr>
<script type="text/javascript">
<!--
function ClothWindow() {
Cloth_Window = window.open("images/LargeCloth.htm","WindowLargeCloth", "width=300,height=472,scrollbars=yes");
Cloth-Window.focus();
}
document.writeln("<a href='#' onClick='ClothWindow()'>Large view [new window]<\/a>");
//-->
</script>
<noscript>
<a href="images/cloths/LargeCloth.htm">Large view</a></div>
</noscript>
works, and validates. Rather a load of script per link, though.
My javascript ignorance is causing me a bit of a headache, but I think there should be some way of declaring the Cloth-Window function once, so that it can accept the url for the specific new window required for a given link. I'll look for that - but if anyone can drop me a hint I'd appreciate it.
<div>
<script type="text/javascript">
<!--
function ClothWindow() {
Cloth_Window = window.open("images/LargeCloth.htm","WindowLargeCloth", "width=300,height=472,scrollbars=yes");
Cloth-Window.focus();
}
document.writeln("<a href='#' onClick='ClothWindow()'>Large view [new window]<\/a>");
//-->
</script>
</div>
<noscript>
<div>
<a href="images/cloths/LargeCloth.htm">Large view</a></div>
</div>
</noscript>
head section of your page, either inline or in an included file. Rather than using a separate
noscript block (which leaves in place a non-functioning link for non-JS users), you should just use the standard href link as the backup, much like you had in your original example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test template</title>
<script type="text/javascript">
<!--
function ClothWindow(theURL) {
Cloth_Window = window.open(theURL,"WindowLargeCloth", "width=300,height=472,scrollbars=yes");
}
//-->
</script>
</head>
<body>
<p><a href="images/cloths/large-cloth-name.jpg" target="_blank" [b]onclick="ClothWindow(this.href);return false;"[/b]>Large view</a></p>
</body>
</html> Whilst the
target attribute is not included on the HTML 4.01 Strict specification, its use in this circumstance is harmless.