Solved

W3C validation of javascript in HTML 4.01 Frameset

Posted on 2014-04-05
14
460 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I use Javascript to insure proper entry of URL? 6 27
Compute age Html 2 27
Echo'd values in dropdowns 6 30
Prevent certain words from being typed in a form 6 31
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

726 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