简体   繁体   中英

is it possible to load a picture in an alert box?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM