javascript - Pop-up window when clicking on an image in my HTML page - Stack Overflow

I know this question has been asked before, but mine is a little different.I know tthat to do a popup o

I know this question has been asked before, but mine is a little different.

I know tthat to do a popup of a thumbnail i have to use Javascript and give te image location. however, what i want to do is this;

<IMG SRC="test.png" ALT="test1" WIDTH=32 HEIGHT=32 onclick="openWin(test.png)"></a> 

where test.PNG is a picture i just queried from the database in SQLPLUS. i do not have a local copy and i do not know the path to id. when i write the javascript function for this, i wrote:

<script language="JavaScript">

function openWin(img) {
    window.open(img);

}
</script>

however, i keep getting a URL\image.png does not exist. How can i get this working? it has to work for an arbitrary number of images, depending on how many actually meet the requirements of the query.

the test.png does not actually exist, i wanted to see becuase it shows as a broken image icon in my table, but when i click on it, it says the URL does not exist.

I know this question has been asked before, but mine is a little different.

I know tthat to do a popup of a thumbnail i have to use Javascript and give te image location. however, what i want to do is this;

<IMG SRC="test.png" ALT="test1" WIDTH=32 HEIGHT=32 onclick="openWin(test.png)"></a> 

where test.PNG is a picture i just queried from the database in SQLPLUS. i do not have a local copy and i do not know the path to id. when i write the javascript function for this, i wrote:

<script language="JavaScript">

function openWin(img) {
    window.open(img);

}
</script>

however, i keep getting a URL\image.png does not exist. How can i get this working? it has to work for an arbitrary number of images, depending on how many actually meet the requirements of the query.

the test.png does not actually exist, i wanted to see becuase it shows as a broken image icon in my table, but when i click on it, it says the URL does not exist.

Share Improve this question edited Apr 1, 2015 at 3:17 Raptor 54.3k47 gold badges248 silver badges399 bronze badges asked Apr 1, 2015 at 2:58 MD-4MD-4 3112 gold badges4 silver badges12 bronze badges 3
  • 1 Your HTML code is awful. Use lowercase html tags, surround attribute with quotes, separate onclick from html tags, surround string values with single quotes, stray </a> tag found and the language="JavaScript" has been deprecated for years. Ouch. – Raptor Commented Apr 1, 2015 at 3:03
  • 2 So you're trying to load an image that doesn't exist, and you don't like receiving an error that it doesn't exist? That's how it's supposed to work! If you don't want the error, don't attach an onclick handler for images which don't exist. – Simon MᶜKenzie Commented Apr 1, 2015 at 3:04
  • i understand the image does not exist. what i want to do is have the broken thumbnail icon i get in my table that tells me the image is not there and make it bigger when i click on it. that way, when i have an actual image, it will make it bigger on click – MD-4 Commented Apr 2, 2015 at 0:15
Add a ment  | 

1 Answer 1

Reset to default 2

Screw Javascript. You don't need Javascript for this. Lose the 'onclick' and put 'target="_Blank"' in an 'href' tag around the 'img' tag.

Example:

<a href="YourLink" target="_Blank">
    <img src="test.png" alt="Put something more exciting here." width="32" height="32" />
</a>

All good? By the way, this isn't PHP, my friend. Hehe. Wrong hashtag.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744844675a4596761.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信