How can I make the link open in a new small window?

I have images on a web page that I want to link to another site, but in a new window of a certain size. In Dreamweaver, I used Window> Behaviors> onMouseClick, but for some reason this does not work. Image is not recognized as a link.

Is there any other way that I can open the link in a new window of a given size and actually work this time?

Here is the code generated by Dreamweaver:

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

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

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')" />
+3
source share
1 answer

Ok, this works for me in Opera. This is also valid HTML.

<!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>

, () , "" ; () -, javascript . ( "Return false" "onclick" , javascript . "False" .)

+8

Source: https://habr.com/ru/post/1728956/


All Articles