0

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

16 Comments

javascript: in the attribute is not required, some even say it should never be there.
@MMM That pseudo-protocol in attribute is usefull when using more than one scripting languages within the same page.
@Starx..i am getting a cross mark .used it this way generator.document.write('<img src="/img/save_orange.gif" border=0" onclick="self.close()"></img>')
@Teemu: Since Netscape the default scripting language is JavaScript.
@rcky, <img> is a self closing tag, you dont need the additional </img>
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.