如何使链接在新的小窗口中打开?
我想将网页上的图像链接到另一个网站,但位于特定大小的新窗口中。在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,这在 Opera 中对我有用。它也是有效的 HTML。
这更好:
更好是因为(a)有一个链接,所以你会看到鼠标的“手”图标; (b) 该链接实际上到达某个地方,因此关闭 javascript 的人仍然可以访问内容。 (“onclick”属性上的“return false”意味着打开了 javascript 的人只能获得弹出链接。“false”会阻止浏览器跟踪正常链接。)
Well, this works for me in Opera. It's valid HTML, too.
And this is better:
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.)