最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - is it possible to load a picture in an alert box? - Stack Overflow

programmeradmin10浏览0评论

I am trying to have a picture to load onclick into an alert box but I am getting "[object HTMLImageElement]" where the picture should be.

This is what I have:

 function joePic(){
 var joe_fat = new Image;
 joe_fat.src = "pic1.jpg";
 alert (joe_fat);
 }

 <input type="button" value="Click here it find out" name="joePhoto" onclick="joePic()" 
 height="150" width="150" />

Is this possible?

I am trying to have a picture to load onclick into an alert box but I am getting "[object HTMLImageElement]" where the picture should be.

This is what I have:

 function joePic(){
 var joe_fat = new Image;
 joe_fat.src = "pic1.jpg";
 alert (joe_fat);
 }

 <input type="button" value="Click here it find out" name="joePhoto" onclick="joePic()" 
 height="150" width="150" />

Is this possible?

Share Improve this question edited Nov 9, 2011 at 21:00 pad 41.3k7 gold badges94 silver badges168 bronze badges asked Nov 9, 2011 at 20:44 OvercrankedOvercranked 1753 silver badges14 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 9

No, you can only put plain text (and linebreaks/carriage returns) into an alert box. If you need 'fancy' popups, you'll have to simulate them with a floating overlay on your page.

probably your best bet for this is to use dialog in jquery ui or use one of the separate plugins like colorbox for jquery.

Could also look through here to see if you can find something suitable

发布评论

评论列表(0)

  1. 暂无评论