Solved

W3C validation of javascript in HTML 4.01 Frameset

Posted on 2014-04-05
14
458 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
ID: 39980704
Why is the closing </script> split up like this </sc'+'ript>'?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39980731
The opening <script> tag is too.
0
 

Author Comment

by:ddantes
ID: 39980753
I'm embarrassed to admit, I have no idea.  I'm guessing  it is some kind of escape which frameset requires.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39980798
Not that I know of.
0
 

Author Comment

by:ddantes
ID: 39980830
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 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 39980899
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
 

Author Comment

by:ddantes
ID: 39980937
Thank you for your testing.
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 300 total points
ID: 39980953
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 83

Expert Comment

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

Expert Comment

by:Robert Schutt
ID: 39981073
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
ID: 39981088
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
ID: 39981391
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
ID: 39981473
Great, thanks.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

816 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

11 Experts available now in Live!

Get 1:1 Help Now