W3C validation of javascript in HTML 4.01 Frameset

I have a page with DOCTYPE 4.01 Frameset, and would like it to validate with W3C.  The code parser objects so some javascript on the page:
 
Line 12, Column 119: delimiter "'" invalid: only S separators and TAGC allowed here … src="data/rezdata.js?'+Math.random()+'" type="text/javascript"></sc'+'ript>');

Error Line 12, Column 119: end tag for element "SC" which is not open
… src="data/rezdata.js?'+Math.random()+'" type="text/javascript"></sc'+'ript>');

I wonder if there is an equivalent of CData which can be used to shield these lines from the code parser?  Here is the code which causes the errors:

<script type="text/javascript">
document.writeln('<sc'+'ript language="JavaScript" src="data/rezdata.js?'+Math.random()+'" type="text/javascript"></sc'+'ript>');
</script>
ddantesAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Robert SchuttConnect With a Mentor Software EngineerCommented:
The validator triggers on: </

It sees an html end tag which is invalid because of the broken up string.

The validator refers to this page for a generic explanation and solution: http://www.htmlhelp.com/tools/validator/problems.html#script

So basically just precede a slash in this situation with a backslash so it won't be recognised as an html end tag.

Breaking up script tags is usually not necessary anymore. I've used stuff like this in the past to stop browsers or even editors from parsing strings like that as actual html tags and mess up rendering or formatting.
0
 
Scott Fell, EE MVEDeveloperCommented:
Why is the closing </script> split up like this </sc'+'ript>'?
0
 
Dave BaldwinFixer of ProblemsCommented:
The opening <script> tag is too.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ddantesAuthor Commented:
I'm embarrassed to admit, I have no idea.  I'm guessing  it is some kind of escape which frameset requires.
0
 
Dave BaldwinFixer of ProblemsCommented:
Not that I know of.
0
 
ddantesAuthor Commented:
I tried re-writing that line of code, without the interruptions in the word "script".
The page no longer worked.  It is a frameset parent, and it did not load the child content.
0
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
I rewrote it several ways.  Splitting up the string did clear one error but I could not get the javascript that it loaded to run.  If your page works in all the browsers, then you'll have to ignore that 'error'.
0
 
ddantesAuthor Commented:
Thank you for your testing.
0
 
Dave BaldwinFixer of ProblemsCommented:
Firefox didn't like it without the split.
0
 
Robert SchuttSoftware EngineerCommented:
How strange, maybe it's a combination of problems?

I've tested in Firefox with just an alert in the included .js and it worked fine:
capture FireBugunless I missed something in my setup I feel that would be a better solution because it also validates: http://validator.w3.org/check?uri=http%3A%2F%2Fschutt.nl%2Fee%2FQ_28405988%2Findex2.htm

But of course if there is a reason to split the script tags then that's fine but still, using the backslash, accepting the validation error is not necessary.
0
 
Scott Fell, EE MVEDeveloperCommented:
Dave or Robert, any insight on his other question about why framesets are causing issues on Expression Web. I'm out of ideas.  http://www.experts-exchange.com/Web_Development/WebApplications/Q_28405995.html
0
 
ddantesAuthor Commented:
Robert:  Thank you, your solution worked.  The pages perform their function and the code validates.  I've requested attention to reopen the question for awarding points.
0
 
Robert SchuttSoftware EngineerCommented:
Great, thanks.
0
All Courses

From novice to tech pro — start learning today.