views:

168

answers:

1

I have images on a webpage that I want to have linked to another website, but in a new window of a certain size. In Dreamweaver, I used Window > Behaviors > onMouseClick, but for some reason, that isn't working. The image isn't recognized as a link.

Is there any other way I can have it open a link in a new window of a set size, and actually have it work this time?

Thanks for your help

EDIT:

here is the code that is being used:

<script language="JavaScript">
<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>

the link:

<img src="images/portfolio/featured1.jpg" alt="Google" width="241"     height="200" border="0" onclick="MM_openBrWindow('http://www.google.com','google','scrollbars=yes,width=650,height=500')" />
+2  A: 

Well, this works for me in Opera. It's valid HTML, too.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Test popup</title>
</head>

<body>

<script type="text/javascript">
<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>

<p>the link:
<img src="notice.png"
    alt="Google"
    width="241" height="200"
    style="border: 0;"
    onclick="MM_openBrWindow('http://www.google.com','google','scrollbars=yes,width=650,height=500')"&gt;


</body>
</html>

And this is better:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Test popup</title>
</head>

<body>

<script type="text/javascript">
<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>

<p>the link:
<a href="http://www.google.com" onclick="MM_openBrWindow('http://www.google.com','google','scrollbars=yes,width=650,height=500'); return false;">

<img src="notice.png"
    alt="Google"
    width="241" height="200"
    style="border: 0;"></a>


</body>
</html>

It's better because (a) there's a link, so you'll see the "hand" icon for the mouse; and (b) the link actually goes somewhere, so people with javascript turned off can still get to the content. (The "return false" on the "onclick" attribute means that people with javascript turned on only get the popup link. The "false" stops the browser following the normal link.)

TRiG
yea, this worked. i don';t know why the actual dreamweaver code didn't work though. Thanks a lot.
I've added a second version since you made your comment. The second is, I think, better.
TRiG
yea, i think i'll use the second version. thanks for your help.
+1 better answer :)
Shoban