简体   繁体   中英

How to add image button to a link using html in javascript

The image button is not working perfectly.. any suggestions ?

The current code on which i am working is:-

var generator = window.open (); 
 generator.document.write('<html><head><title>Pop uP</title>');
generator.document.write('<p style="color:#C52B27;">');
generator.document.write(message);
 generator.document.write('</p>');
generator.document.write('</head><body>');

 generator.document.write('<a href="javascript:self.close()"><img src="/img/save_orange.gif" border=0"><\/a>');
generator.document.write('</body></html>');
generator.document.close();

Bind a js snippet to onclick event of the image

<img src="/img/save_orange.gif" border="0" onclick="self.close()">

According to this doc , self.close() only works if the document is open by window.open() method. So, on this case you might want to use windows.close()

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