March 7, 2012

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

Question by rcky

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

Answer by Starx

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

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!