Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  15] [ 4]  / answers: 1 / hits: 24931  / 15 Years ago, mon, january 18, 2010, 12:00:00

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?



Here is the code produced by Dreamweaver:



<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') />

More From » html

 Answers
49

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>
<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')>


</body>
</html>


And this is better:



<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd>
<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.)


[#97804] Thursday, January 14, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brendaw

Total Points: 508
Total Questions: 90
Total Answers: 100

Location: Maldives
Member since Sat, Jan 29, 2022
2 Years ago
;