Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 19th, 2004, 10:22 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default 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

__________________
-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old January 20th, 2004, 05:12 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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
 
Old January 20th, 2004, 06:27 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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

 
Old January 21st, 2004, 05:01 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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
 
Old January 21st, 2004, 04:28 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Thanks, Joe.

Snib






Similar Threads
Thread Thread Starter Forum Replies Last Post
Write a XML Document using java. vinitpugaliya XML 0 January 8th, 2007 06:26 AM
Document.write hussainm Javascript How-To 2 July 12th, 2006 05:20 AM
Write Nested XML document into SQL Server tables boondocksaint20 VB.NET 0 May 2nd, 2006 12:35 PM
document.write into cell or td with Opera crmpicco Javascript How-To 0 April 11th, 2006 04:58 AM
Write a document to the server Hal Emmerich Javascript How-To 1 November 13th, 2004 07:15 AM





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