如何使链接在新的小窗口中打开?

发布于 2024-08-18 10:25:59 字数 630 浏览 3 评论 0原文

我想将网页上的图像链接到另一个网站,但位于特定大小的新窗口中。在 Dreamweaver 中,我使用了 Window >行为> onMouseClick,但由于某种原因,这不起作用。该图像未被识别为链接。

有没有其他方法可以让它在设定大小的新窗口中打开链接,并且这次实际上可以正常工作?

这是 Dreamweaver 生成的代码:

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

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

链接:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

翻了热茶 2024-08-25 10:25:59

嗯,这在 Opera 中对我有用。它也是有效的 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>

这更好:

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

更好是因为(a)有一个链接,所以你会看到鼠标的“手”图标; (b) 该链接实际上到达某个地方,因此关闭 javascript 的人仍然可以访问内容。 (“onclick”属性上的“return false”意味着打开了 javascript 的人只能获得弹出链接。“false”会阻止浏览器跟踪正常链接。)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文