Solved

W3C validation of javascript in HTML 4.01 Frameset

Posted on 2014-04-05
14
456 Views
Last Modified: 2014-04-07
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>
0
Comment
Question by:ddantes
  • 4
  • 4
  • 3
  • +1
14 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
Why is the closing </script> split up like this </sc'+'ript>'?
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
The opening <script> tag is too.
0
 

Author Comment

by:ddantes
Comment Utility
I'm embarrassed to admit, I have no idea.  I'm guessing  it is some kind of escape which frameset requires.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Not that I know of.
0
 

Author Comment

by:ddantes
Comment Utility
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
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:ddantes
Comment Utility
Thank you for your testing.
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 300 total points
Comment Utility
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
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Firefox didn't like it without the split.
0
 
LVL 35

Expert Comment

by:Robert Schutt
Comment Utility
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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
 

Author Comment

by:ddantes
Comment Utility
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
 
LVL 35

Expert Comment

by:Robert Schutt
Comment Utility
Great, thanks.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now