View Full Version : JS validator?

03-13-2004, 11:47 PM
Is there such a think like a JS validator, cause when i use a stricked doctype my js wont work :(, I guess cause it isnt valid js, but how can i find out what i did wrong?

03-15-2004, 01:31 AM
You might try running your script through JSLint (http://www.crockford.com/javascript/jslint.html), though we can't really help much without seeing any code.

03-16-2004, 02:09 AM
ok, i didnt want to post the whole JS, but here it comes:

var Interval = 0;
var i = 0;
var show=0;

function PrintPage(){

function Source(){
window.open(location).location="view-source:" + window.location.href

function HideAll(){if(show==1){show=1;Show();}}

function ChangeImg(id){document.getElementById(id+'Img').src = "Pic/ArrowGray.bmp";}

function UnImg(id){document.getElementById(id+'Img').src = "Pic/Arrow.bmp";}

function Show(){
Interval = setInterval('Swoon()', 1);

Interval = setInterval('Create()', 1);

function Create(){
document.getElementById('Directory0').style.width = i;

function Swoon(){
document.getElementById('Directory0').style.width = i;
document.getElementById('Directory1').style.width = i;
document.getElementById('Directory2').style.width = i;
document.getElementById('Directory3').style.width = i;

function Display(a){
document.getElementById('L'+a).style.display = 'block';
document.getElementById('L'+a).style.top = a*25-25;

function Hide(b,c){
while(b<=c){document.getElementById('L'+b).style.display = 'none';

function Color(Id){
document.getElementById(Id).style.backgroundColor = '#e3e3e3';

function UnColor(Id){
document.getElementById(Id).style.backgroundColor = '#FFFFFF';

document.oncontextmenu = Position;

function HideMenu(){
document.getElementById('ContextMenu').style.visibility = 'hidden';

function Position(e){
document.getElementById('ContextMenu').style.visibility = 'visible';
document.getElementById('ContextMenu').style.top = e.pageY
document.getElementById('ContextMenu').style.left = e.pageX + 20
return false;

function ChangeContent(Num){
document.getElementById('Table').style.visibility = 'hidden';
document.getElementById(Num).style.visibility = 'visible';

thanks for any help, i know its not valid coding cause with a doctype it wont work :(

Roy Sinclair
03-16-2004, 03:29 PM
i know its not valid coding cause with a doctype it wont work

This tells me that the problem isn't in validating Javascript, you're trying to validate HTML that contains some Javascript. The problem is that Javascript is never going to be "good html" since it's a different language entirely. The key to validating then is to hide the Javascript from the HTML validator.

Put it into an external file and then your HTML will validate. The other option is to place the inline Javascript into CDATA comment


03-16-2004, 11:26 PM
no, no, the page DOES validate, but my script does NOT work in a strict doctype :(

Roy Sinclair
03-17-2004, 05:24 PM
I think we had another occurance of that recently in another thread. IIRC, we never did find the exact reason for the problem.

In your case I'd try adding simple alerts to the functions that don't seem to be working to let you know if the function is even getting called.

If you can get a simple demonstration page going somewhere we can help you chase this down and maybe then have a better answer the next time this comes up.

03-21-2004, 04:10 PM
got the site up, please ignore the add :(, anyways if u save the page and add a strick doctype then it wont work :(


or attachment

Roy Sinclair
03-25-2004, 04:43 PM
I added a strict doctype to it and thought it didn't work until I moved the mouse over the TEXT of the link and up popped the menu.

Somehow, somewhere in the CSS file those A tags need to be given a width and height that's 100% of the containing block so they'll work the same in both Quirks and compliant mode.

03-26-2004, 12:11 AM
but the rightclick script still dosnt work :(

03-26-2004, 04:32 AM
about jslint...
Why does it consider ++ as harmfull?
And also, how can I rapidly find character 105...

03-26-2004, 12:21 PM
Well, Douglas Crockford does explain that, though I think he's taking it a bit too far.


Roy Sinclair
03-26-2004, 04:25 PM
Originally posted by JAVAEOC
but the rightclick script still dosnt work :(

It does for me (after I push the "Enable Right Click" button).

03-27-2004, 12:44 AM
Roy even after u added a strick doctype?

03-27-2004, 03:28 AM
Liorean: The links you gave me...
That's a lot of stuff.
From what I read yet, I havn't had an answer but I sure am getting a javascript course :)
I'll tell you once I've read everything :)
Thanks a lot

Roy Sinclair
03-27-2004, 04:36 PM
Originally posted by JAVAEOC
Roy even after u added a strick doctype?

Even with a strict doctype.

This one to be precise:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

03-27-2004, 06:34 PM
I read through your links and I finally got my answer.

The ++ (post-increment) and -- (post-decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling to viruses and other security menaces. jslint does not expect to see them by default. jslint currently tolerates the pre-increment and pre-decrement forms.

but I don't understand why using ++ would enable viruses...
Anyways, from now on I will use ++i; instead of i++;

03-27-2004, 06:41 PM
That's a problem with other languages than JavaScript. The JavaScript runtime doesn't allow buffer overruns. For an example of the type of problems it may cause, have a look at <http://www.caida.org/analysis/security/witty/>.

03-27-2004, 07:11 PM
That seems a little too complexe for me at this time in my life. I'll wait a little before I learn this :(
Still, thank you :)

03-28-2004, 02:32 PM
It works, I am sorry I must have messed up when i tried to add it, but now it even works for me :(, very sorry.

but what is the difference between xhtml 1 and xhtml 1.1>?

03-28-2004, 02:47 PM
XHTML1.1 has only one DTD, matching XHTML1.0 Strict.
XHTML1.1 MUST NOT be sent as 'text/html'.
XHTML1.1 is made so that you should be able to make a custom DTD from the modules for it or from custom modules, and still have it be valid XHTML1.1.
XHTML1.1 may support namespaces.

03-29-2004, 11:05 PM
so which one should i use to validate my page?

XHTML 1 or XHTML 1.1

if my page is valid for both just depending on the doctype ....

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum