HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 16th, 1999, 12:52 PM
2ki
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Hi,

I need to generate a new document that will contain javascripting with the document.write method

I create a string :
tmp = "";
tmp += "<HTML>......";
tmp += "....<SCRIPT>";
tmp += "............";
tmp += "............";
tmp += "...</SCRIPT>";
tmp += "...</HTML>";

And when I do the instruction :
document.open();
document.write(tmp);
document.close();

I crashes when the browser evaluates the </script> in the tmp string !!!

Does anybody has an idea of the way to do it ???

Thanks for any help.

2ki.

Reply With Quote
  #2  
Old December 23rd, 1999, 03:53 AM
PAV
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I don't know what you have placed between the <SCRIPT>..</SCRIPT> tags, but it could be that there are certain characters (like ", etc.) which cause it.
You should 'escape' these characters with an , e.g. '"' (to display " itself).
Check this or else let us know what is between those tags.

Good christmas!

Reply With Quote
  #3  
Old December 27th, 1999, 11:49 AM
time2brew
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I would suggest putting the javascript between your script tags as a function in the same file you are doing your document.write() from.

then the <body> can have an onload event that calls this function.

ex.

function initNewHTML(){
// your script here
}
function CreateNewHtml(){
var str="";
str +="<html><body onload='initNewHTML()'></body></html>"
document.open();
document.write(str);
docuent.close();
}

Reply With Quote
  #4  
Old January 27th, 2000, 10:02 AM
Bjoern Bjoern is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 1999
Location: Muenster, NRW, Germany
Posts: 17 Bjoern User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I agree to the previous posts (about escaping special characters like /) but there is another thing to consider:
if you do a document.write in the same document where the var is you want to write it might well be that you kill the whole skript since the browser starts a whole new document. This will kill the skript and the var.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > error using document.write("........");

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap