validating my site - javascript causing errors

Locked
baggiesmad
Joomla! Explorer
Joomla! Explorer
Posts: 419
Joined: Tue Feb 21, 2006 11:10 am

validating my site - javascript causing errors

Post by baggiesmad » Fri Dec 15, 2006 10:29 am

Im trying to clean up the code in my site.

I currently have 15 errors left and some of them are being caused by some javascript which I have in my index.php.

is there anyway I can get the validator to ignore this?

let me know if you want me to post these errors up.


any help would be great.  :)
Last edited by baggiesmad on Thu Dec 21, 2006 12:32 pm, edited 1 time in total.

User avatar
absalom
Joomla! Ace
Joomla! Ace
Posts: 1199
Joined: Thu Aug 18, 2005 12:37 am
Location: Melbourne, Australia
Contact:

Re: validating my site - javascript causing errors

Post by absalom » Sat Dec 16, 2006 9:24 am

You have to get your Javascript well-formed.

What's to blame ? The template ?
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia

baggiesmad
Joomla! Explorer
Joomla! Explorer
Posts: 419
Joined: Tue Feb 21, 2006 11:10 am

Re: validating my site - javascript causing errors

Post by baggiesmad » Mon Dec 18, 2006 9:05 am

the errors are appearing within the java script.

I didnt create the java script myself I got it from hotscripts.com

is there anything I can do?

User avatar
absalom
Joomla! Ace
Joomla! Ace
Posts: 1199
Joined: Thu Aug 18, 2005 12:37 am
Location: Melbourne, Australia
Contact:

Re: validating my site - javascript causing errors

Post by absalom » Mon Dec 18, 2006 10:20 am

Fix the script. It's the only way..

I've been churning my way through well-formed JS on a couple of projects now, so if you could tell me the script, I might be able to fix it..
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia

baggiesmad
Joomla! Explorer
Joomla! Explorer
Posts: 419
Joined: Tue Feb 21, 2006 11:10 am

Re: validating my site - javascript causing errors

Post by baggiesmad » Mon Dec 18, 2006 10:26 am

Sure.

here is the three sets of javascript from the top of my index.php page.

Code: Select all

<script language="JavaScript" type="text/javascript">
<!-- 
function bookmarksite(title){
if (document.all)
window.external.AddFavorite(window.location.href, title);
else if (window.sidebar)
window.sidebar.addPanel(title, window.location.href, "")
}
// -->
</script>
<script language="JavaScript">
var gAutoPrint = true; // Tells whether to automatically call the print function

function printSpecial()
{
if (document.getElementById != null)
{
var html = '<HTML>\n<HEAD>\n';

if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}

html += '\n</HE>\n<BODY>\n';

var printReadyElem = document.getElementById("printReady");

if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady function");
return;
}

html += '\n</BO>\n</HT>';

var printWin = window.open("","printSpecial");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint)
printWin.print();
}
else
{
alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
}
}

</script>
and here are the errors from the validating tool.

Code: Select all

# Error  Line 23 column 29: required attribute "type" not specified.

<script language="JavaScript">

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.

✉
# Error Line 30 column 17: element "HTML" undefined.

var html = '<HTML>\n<HEAD>\n';

You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by:

    * incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element),
    * by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).
    * by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case.

✉
# Error Line 30 column 25: element "HEAD" undefined.

var html = '<HTML>\n<HEAD>\n';

✉
# Error Line 39 column 15: end tag for element "HE" which is not open.

html += '\n</HE>\n<BODY>\n';

The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

If this error occured in a script section of your document, you should probably read this FAQ entry.

✉
# Error Line 39 column 23: element "BODY" undefined.

html += '\n</HE>\n<BODY>\n';

✉
# Error Line 53 column 15: end tag for element "BO" which is not open.

html += '\n</BO>\n</HT>';

✉
# Error Line 53 column 22: end tag for element "HT" which is not open.

html += '\n</BO>\n</HT>';

✉
# Error Line 68 column 8: end tag for "BODY" omitted, but OMITTAG NO was specified.

</script>

You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".

✉
# Info Line 39 column 18: start tag was here.

html += '\n</HE>\n<BODY>\n';

# Error Line 68 column 8: end tag for "HEAD" omitted, but OMITTAG NO was specified.

</script>

✉
# Info Line 30 column 20: start tag was here.

var html = '<HTML>\n<HEAD>\n';

# Error Line 68 column 8: end tag for "HTML" omitted, but OMITTAG NO was specified.

</script>

✉
# Info Line 30 column 12: start tag was here.

var html = '<HTML>\n<HEAD>\n';

# Error Line 70 column 22: document type does not allow element "style" here.

<style type="text/css">

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

✉
# Error Line 80 column 57: there is no attribute "background".

...height="713" valign="top" background="http://www.mysite/templates/der_bl

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.

✉
# Error Line 80 column 141: there is no attribute "height".

...es/bg.jpg"><table width="884" height="720" border="0" cellpadding="0" cellspa

User avatar
absalom
Joomla! Ace
Joomla! Ace
Posts: 1199
Joined: Thu Aug 18, 2005 12:37 am
Location: Melbourne, Australia
Contact:

Re: validating my site - javascript causing errors

Post by absalom » Mon Dec 18, 2006 10:33 am

Arrgh..  :o Inline HTML inside JS. Not a good sight..

Ideally, what you'd do is push all this inline JS to a JS file and then reference the final JS inside the template. I need to know where you found your code on hotscripts to do this correctly.

Apart from that, it's just some design issues on the template itself:
  • You have a malformed style call somewhere inside your template
  • You have height and background in areas they shouldn't be called - again template design issues
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia

baggiesmad
Joomla! Explorer
Joomla! Explorer
Posts: 419
Joined: Tue Feb 21, 2006 11:10 am

Re: validating my site - javascript causing errors

Post by baggiesmad » Mon Dec 18, 2006 10:41 am

absalom wrote: Arrgh..  :o Inline HTML inside JS. Not a good sight..

Ideally, what you'd do is push all this inline JS to a JS file and then reference the final JS inside the template. I need to know where you found your code on hotscripts to do this correctly.

Apart from that, it's just some design issues on the template itself:
  • You have a malformed style call somewhere inside your template
  • You have height and background in areas they shouldn't be called - again template design issues
All i can remember was I got the "bookmark our site" script from there and found the "print this page" scrip just by just google.

I will remove them from the page while I try to correct the errors found in the template.

baggiesmad
Joomla! Explorer
Joomla! Explorer
Posts: 419
Joined: Tue Feb 21, 2006 11:10 am

Re: validating my site - javascript causing errors

Post by baggiesmad » Mon Dec 18, 2006 12:32 pm

Ive taken out the javascript and corrected the code which now passes the validator.

Ive just checked my css page I Im having 1 Problem with it.

Code: Select all

230  	  	 Unknown pseudo-element or pseudo-class :visit
I just used the solarflare css page and edited it to what i required in my page.

does anyone know how to fix this error  :(

User avatar
absalom
Joomla! Ace
Joomla! Ace
Posts: 1199
Joined: Thu Aug 18, 2005 12:37 am
Location: Melbourne, Australia
Contact:

Re: validating my site - javascript causing errors

Post by absalom » Tue Dec 19, 2006 1:02 am

It should be :visited as a pseudo class.
Design with integrity : Web accessible solutions
http://www.absalom.biz
http://twitter.com/absalomedia

baggiesmad
Joomla! Explorer
Joomla! Explorer
Posts: 419
Joined: Tue Feb 21, 2006 11:10 am

Re: validating my site - javascript causing errors

Post by baggiesmad » Tue Dec 19, 2006 8:56 am

absalom wrote: It should be :visited as a pseudo class.
;D Cheers mate.

That sorted the error.

What do i do about the warnings within the validation of my css? Should I worry about them?

User avatar
wheeqo
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 126
Joined: Sun Jan 29, 2006 6:11 am
Location: Paris van Java
Contact:

Re: validating my site - javascript causing errors

Post by wheeqo » Wed Jun 06, 2007 10:42 am

try to change

Code: Select all

<script language="JavaScript">
to

Code: Select all

<script language="JavaScript" type="text/javascript">
Industrial Engineering Community: http://www.ie.stttelkom.ac.id/forum


Locked

Return to “Design and Accessibility - Archived”