rcky
rcky

Reputation: 287

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();

Upvotes: 0

Views: 408

Answers (1)

Starx
Starx

Reputation: 79041

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()

Upvotes: 1

Related Questions