Connecting Tech Pros Worldwide Help | Site Map

Javascript document.write problem

Newbie
 
Join Date: Aug 2009
Posts: 1
#1: Aug 28 '09
I have selection box and after the selection I want to add some text on a page dependent on the selection. Populating form variables does not give the formatting I want. How do I do it easily without side server technologies?

I thought I had found the answer. I used document.write in my function, similar to below.

Expand|Select|Wrap|Line Numbers
  1.  
  2. function dowrite(digit)
  3. {
  4.    if (digit == 1)
  5.    {
  6.       data="<html><head></head><body>TEXT HERE INCLUDING TABLES & IMAGES</body></head></html>";
  7.    }
  8.   document.write(data);
  9. }
  10.  
This opens up a new page nicely. This is where the problems start. IE7 only will output so much and will not display the rest. Even stranger is that when you view source, save it as a html document and open the saved html document, the document displays fine. Firefox gives no such problems but the document never completes loading. I have tried document.writeln but same issue.

Please help. Much appreciated.
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,126
#2: Aug 28 '09

re: Javascript document.write problem


you might use:

Expand|Select|Wrap|Line Numbers
  1. document.open();
before write and

Expand|Select|Wrap|Line Numbers
  1. document.close();
after it. to avoid the firefox-issue. could you explain the IE issue a bit more?

kind regards
Reply