p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   write() without clearing old document (http://p2p.wrox.com/showthread.php?t=8334)

Snib January 19th, 2004 10:22 PM

write() without clearing old document
 
My page opens a new window with existing data, and I want to add to the page without clearing out the old document. Is this possible? I have tried (assuming newwin is my new window)

newwin.document.write("blahblah")

and

newwin.document.close();
newwin.document.write("blahblah");

but both clear out the new page to put the new data. Please help!

Thanks,

Snib


joefawcett January 20th, 2004 05:12 AM

If you don't want to use textboxes then have a div in the page with the id 'divMessage' then a function such as:
Code:

function showMessage(Html, Append)
{
  var oDiv = document.getElementById("divMessage");
  if (Append)
  {
   oDiv.innerHTML += Html;
  }
  else
  {
    oDiv.innerHTML = Html;
  }
}

to call use:
Code:

showMessage("<b>Hello</b>");
to clear the display and show an enboldened 'Hello', use:
Code:

showMessage("<i>World</i>", true);
to add an italicised 'World'.

--

Joe

Snib January 20th, 2004 06:27 PM

Joe,

Thanks, I didn't think of that!

However, is there a way to do this into, say, text files? I assume not...

Thanks,

Snib


joefawcett January 21st, 2004 05:01 AM

Not unless client security levels are set to a very low level in the relevant zone. If they are, either a company intranet or the like, then use the FileSystemObject on Windows machines. Plenty of examples on the web.

--

Joe

Snib January 21st, 2004 04:28 PM

Thanks, Joe.

Snib



All times are GMT -4. The time now is 02:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.