Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

W3C won't validate my working page 1

Status
Not open for further replies.

>> I can't for the life of me figure what's wrong with them

The errors given by the validator usually tell you that.

For the 3rd error, at least, the validator is spot-on. There is no "target" attribute when validating against the strict DTDs. You should remove the attribute, or use JS to get around the issue.

Hope this helps,
Dan
 
Weird that it won't accept that(I think). Now I guess I'll have to come up with some js as you suggested to open a new link.

thanks

"Failure is the tuition you pay for success."
~ Walter Brunell ~
 

>> Weird that it won't accept that(I think).

Why is following the standard "weird"? If you don't like the standards, then don't try to code against them - it's your choice ;o)

As for JS to get around that, this is what I use:

Code:
<a href="wibble.html" onclick="this.target='_blank';">

Hope this helps,
Dan
 
Code:
<a href="wibble.html" onclick="this.target='_blank';">
WORKS

thanks

Can anyone help with the other two?

"Failure is the tuition you pay for success."
~ Walter Brunell ~
 
With the document.write issue, that's a problem with validating code when the validator doesn't understand JS. You can get around it by breaking your string up. So convert this:

Code:
document.write('<div style="page-break-after:always;"></div>');

to this:

Code:
document.write('<div style="page-break-after:always;"></d' + 'iv>');

As for the first error, have you tried taking the advice of the validator? Try wrapping a P tag around your input and see what you get.

Dan
 
Thanks for the suggestion, BillyRayPreachersSon but it didn't work... got these two messages:
Line 303, column 59: delimiter "'" invalid: only S separators and TAGC allowed here
document.write('<div style="page-break-after:always;"></d' + 'iv>');


Line 303, column 59: end tag for element "D" which is not open
document.write('<div style="page-break-after:always;"></d' + 'iv>');
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.


Any other thoughts/suggestions would be appreciated.

thanks again


"Failure is the tuition you pay for success."
~ Walter Brunell ~
 

Why don't you try some other things. Try breaking the strings in different places - I'm sure you don't need me to tell you that there are many ways to break a string up.

I'd try any of the following, if it were my code that were breaking, for example:

Code:
document.write('<div style="page-break-after:always;"><' + '/div>');

document.write('<div style="page-break-after:always;"><' + '/' + 'div>');

document.write('<div style="page-break-after:always;">' + '<' + /div>');

Sooner or later, you'll find a combination that the validator doesn't balk at.

Dan
 
Sorry, didn't mean to tick you off. I'm learning as I'm going. There were 17 original errors. I fixed them all except the ones I asked help for.

I'll try your suggestions.

"Failure is the tuition you pay for success."
~ Walter Brunell ~
 
If you were to put some comments around the javascript "to hide it from old browsers" then the validator will validate your page.

Here is what I would do:

Code:
<script type="text/javascript">
[b][COLOR=red]<!--[/color][/b]
document.write('<div>Blah</div>');
[b][COLOR=red]//-->[/color][/b]
</script>

Hope you get some mileage from this.

Jeff
 
just to add, if you follow Jeff's suggestion for all your scripts it should clear up all the issues I think.

apart from the target="_blank" of course.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems
 
Thanks Jeff and Chris...I inserted the comments but they didn't make a difference. I will of course leave them in for the obvious reason you mentioned.

I broke up the div tag some more as BillyRays suggested and that works.

I also tried wrapping a couple other tags around the input with no luck but am still investigating other possibilities.

"Failure is the tuition you pay for success."
~ Walter Brunell ~
 
Even with comments in, Javascript often seems to confuse the Validator. I'd recommend you always put javascripts into seperate files, like this:
Code:
<script type="text/javascript" src="/js/pagebreak.js"></script>
Where /js/pagebreak.js contains
Code:
if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null)
{
   document.write('<div style="page-break-after:always;"></div>');
}
That way, you won't trouble the validator, you won't have to obfuscate your code unnecessarily, and you'll also cause your pages to load faster - because the Javascripts are cached from page to page.

If you need the [tt]target[/tt] attribute, consider coding that page to HTML4 Transitional instead of Strict. There's a lengthy discussion of this and other options at .


-- Chris Hunt
 
Regarding that one last error...

Try not breaking your input line in two, and surrounding it with DIV tags, (again, as suggested by the validator):

Code:
<div><input type="button" value="Download" onclick="document.location.href='[URL unfurl="true"]http://www.patmcdaniel.com/McDaniel[/URL] resume.doc'"></div>

Dan
 
As for the remaining first problem. I suppose validator expects your form elements to be enclosed in one of the elements it suggests (<p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <pre>, <div>, <address>). If you enclose everything in a form in another <p> it stops nagging:
Code:
<form action="">
  [b]<p>[/b]
    <input ...
    ...
  [b]</p>[/b]
</form>
Hope it helps.
 
Thanks...all errors are gone and I've got my first Valid page.

"Failure is the tuition you pay for success."
~ Walter Brunell ~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top