如何链接图像并定位新窗口

时间:2022-02-26 23:07:31

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?

我有一张图片,如果我点击该图片,我该如何建立一个图像参考,以便在新标签页或我浏览器显示图片的新窗口中打开另一页?

7 个解决方案

#1


36  

<a href="http://www.google.com" target="_blank">
  <img width="220" height="250" border="0" align="center"  src=""/>
</a>

#2


8  

If you use script to navigate to the page, use the open method with the target _blank to open a new window / tab:

如果使用脚本导航到页面,请使用带有目标_blank的open方法打开新窗口/选项卡:

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

但是,如果您希望搜索引擎找到该页面,您应该将图像包装在常规链接中。

#3


5  

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

goreb

#4


4  

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中

#5


3  

<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

看代码

#6


1  

To open in a new tab use:

要在新标签页中打开,请使用:

target = "_blank"

To open in the same tab use:

要在同一个标​​签中打开,请使用:

target = "_self"

#7


-1  

set it's target="_blank"

设置它的目标=“_空白”

#1


36  

<a href="http://www.google.com" target="_blank">
  <img width="220" height="250" border="0" align="center"  src=""/>
</a>

#2


8  

If you use script to navigate to the page, use the open method with the target _blank to open a new window / tab:

如果使用脚本导航到页面,请使用带有目标_blank的open方法打开新窗口/选项卡:

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

但是,如果您希望搜索引擎找到该页面,您应该将图像包装在常规链接中。

#3


5  

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

goreb

#4


4  

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中

#5


3  

<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

看代码

#6


1  

To open in a new tab use:

要在新标签页中打开,请使用:

target = "_blank"

To open in the same tab use:

要在同一个标​​签中打开,请使用:

target = "_self"

#7


-1  

set it's target="_blank"

设置它的目标=“_空白”