Html 如何链接图像并定位到新窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3139811/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to link an image and target a new window
提问by Abid Ali
I have a picture, if I click onto that picture, how can I build an image reference so another page opens in a new tab or a new window of my browser displaying the picture?
我有一张图片,如果我点击那张图片,我如何构建一个图像参考,以便在新选项卡或浏览器的新窗口中打开另一个页面来显示图片?
回答by Salil
<a href="http://www.google.com" target="_blank">
<img width="220" height="250" border="0" align="center" src=""/>
</a>
回答by Guffa
If you use script to navigate to the page, use the open
method with the target _blank
to open a new window / tab:
如果使用脚本导航到页面,请使用open
带有目标的方法_blank
打开一个新窗口/选项卡:
<img src="..." alt="..." onclick="window.open('anotherpage.html', '_blank');" />
However, if you want search engines to find the page, you should just wrap the image in a regular link instead.
但是,如果您希望搜索引擎找到该页面,则应该将图像包装在常规链接中。
回答by gorbis
you can do like this
你可以这样做
<a href="http://www.w3c.org/" target="_blank">W3C Home Page</a>
find this page
找到这个页面
http://www.corelangs.com/html/links/new-window.html
goreb
戈雷布
回答by T Sooraj
<a href="http://www.google.com" target="_blank"> //gives blank window
<img width="220" height="250" border="0" align="center" src=""/> // show image into new window
</a>
See the code
看代码
回答by Arijoon
Assuming you want to show an Image thumbnail which is 50x50 pixels and link to the the actual image you can do
假设您想显示一个 50x50 像素的图像缩略图并链接到您可以执行的实际图像
<a href="path/to/image.jpg" alt="Image description" target="_blank" style="display: inline-block; width: 50px; height; 50px; background-image: url('path/to/image.jpg');"></a>
Of course it's best to give that link a class or id and put it in your css
当然,最好给该链接一个类或 id 并将其放在您的 css 中
回答by Siva Ganesh
To open in a new tab use:
要在新选项卡中打开,请使用:
target = "_blank"
To open in the same tab use:
要在同一选项卡中打开,请使用:
target = "_self"
回答by Jason
set it's target="_blank"
设置它的目标=“_blank”