Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript and ASCII

Status
Not open for further replies.

jessemania

Technical User
Aug 18, 2006
2
0
0
US
This is probably a stupid question but I can't find documentation online. Anywho. I'm having a javascript create another page for me (document.write). On this next page there is a javascript but the {} are jacking up the first script. I assume I need to use ascii but if there is an eaiser way that'd be pretty tight.
Thanks in Advanced,
Jesse
 
As long as they are inside quotes it shouldn't matter. Show some of your code.

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
code:
document.write('<html><head><script language=javascript>function change(y,z){newresults=newresults+y+z;sender.changesmade.value=newresults;}</script><STYLE TYPE-type/css><!--A:visited {color: #FF00FF} font.title {font-size:36;} font.whparable {font-size: 10pt;} font.place {font-size: 8pt;} font.text {font size:10pt;}--></STYLE><title>Data</title></head><body><table border=1>');
document.write(results);
document.write('<FORM NAME=SENDER METHOD=POST ACTION=mailto:><INPUT TYPE=radio NAME=changesmade VALUE=><INPUT TYPE=submit></FORM></table></body></html>');
 
You can try escaping these like so:
Code:
<html><head><script language=javascript>function change(y,z)\{newresults=newresults+y+z;sender.changesmade.value=newresults;\}</script>
[...]

Take Care,
Mike
 
Your problem is not the closing brackets, it's the <script> tags. Javascript goes a little wacky when you nest <script> tags inside strings inside <script> tags. You just have to break up the <script> tag to fix it. This should work:

Code:
document.write('<html><head><scr[!]' + '[/!]ipt language=javascript>function change(y,z){newresults=newresults+y+z;sender.changesmade.value=newresults;}</scr[!]' + '[/!]ipt><STYLE TYPE-type/css><!--A:visited {color: #FF00FF} font.title {font-size:36;} font.whparable {font-size: 10pt;} font.place {font-size: 8pt;} font.text {font size:10pt;}--></STYLE><title>Data</title></head><body><table border=1>');
document.write(results);
document.write('<FORM NAME=SENDER METHOD=POST ACTION=mailto:><INPUT TYPE=radio NAME=changesmade VALUE=><INPUT TYPE=submit></FORM></table></body></html>');

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top