By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,382 Members | 1,645 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,382 IT Pros & Developers. It's quick & easy.

Windows and Javascript - Clear contents.

P: n/a
Hi,

Please Help!

I have developed a custom JSP tag that produces Javascript to create a
window and write HTML and Javascript to that window. This window
displays an error message.

The problem is this. When the page with the custom tag is refreshed
without closing the (error) window the content written to the window
in the first place is written again. Thus, the error message appears
twice. The window source will then basically contain a replica of the
code, appended to the end of the first section of code. What I want
to do is clear the contents of the window before writing the HTML and
Javascript to that window. I have found a method document.clear()
which does not seem to be supported by IE. Does anyone know how I
achieve the same functinality?! Alternatively, I want to be able to
close the window and create a new window (with an error message) but I
don't know how I can check if the window is open. Remember that all
the functionality must be contained within the Javascript output by
the tag (the HTML page where the tag resides cannot be modified).

Any help would be much appreciated. Thanks,

Rob.
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ro***************@accenture.com (Rob Videtta) writes:
The problem is this. When the page with the custom tag is refreshed
without closing the (error) window the content written to the window
in the first place is written again. Thus, the error message appears
twice.
Remember to close the document after writing to it (and open it before).
I.e., the code to write to the error window is

errorWindowRef.document.open();
errorWindowRef.document.write(errorContent);
errorWindowRef.document.close();
The window source will then basically contain a replica of the
code, appended to the end of the first section of code. What I want
to do is clear the contents of the window before writing the HTML and
Javascript to that window. I have found a method document.clear()
which does not seem to be supported by IE. Does anyone know how I
achieve the same functinality?!
Closing and reopening the document should be sufficient.
Alternatively, I want to be able to close the window and create a
new window (with an error message) but I don't know how I can check
if the window is open.


!(errorWindowRef.closed)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
Hi,

Lasse Reichstein Nielsen wrote:
ro***************@accenture.com (Rob Videtta) writes:

The problem is this. When the page with the custom tag is refreshed
without closing the (error) window the content written to the window
in the first place is written again. Thus, the error message appears
twice.

Remember to close the document after writing to it (and open it before).
I.e., the code to write to the error window is

errorWindowRef.document.open();
errorWindowRef.document.write(errorContent);
errorWindowRef.document.close();


Just to be clear, document.write also opens the document if it was not
already open. As such, the call to document.open() before
document.write() is not necessary.

<snip>

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.