Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: JS validator?

  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS validator?

    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?

  • #2
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You might try running your script through JSLint, though we can't really help much without seeing any code.

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, i didnt want to post the whole JS, but here it comes:
    Code:
    var Interval = 0;
    var i = 0;
    var show=0;
    
    function PrintPage(){
    	window.print()
    	}
    
    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(){
    	        if(show==1){
                        if(i>=110){
    		        document.getElementById('Maker').innerHTML="S<br>h<br>o<br>w"
    		        Interval = setInterval('Swoon()', 1);
    			}}
    
    	        if(show==0){
    		document.getElementById('Maker').innerHTML="H<br>i<br>d<br>e"
    		show=1;
                        	if(i<110){
                                    Interval = setInterval('Create()', 1);
                                    document.getElementById('Directory0').style.display='block';
                                    document.getElementById('Directory1').style.display='block';
                                    document.getElementById('Directory2').style.display='block';
                                    document.getElementById('Directory3').style.display='block';
                                    }}}
    
    function Create(){
    	        if(i>=110){clearInterval(Interval);};
                          document.getElementById('Directory0').style.width = i;
                          i+=1;
                          }
    
    function Swoon(){
                   Hide(1,4);
    	        if(i<=0){
                          clearInterval(Interval);
    	 	       show=0;
                          document.getElementById('Directory0').style.display='none';
                          document.getElementById('Directory1').style.display='none';
                          document.getElementById('Directory2').style.display='none';
                          document.getElementById('Directory3').style.display='none';
                          }
                          document.getElementById('Directory0').style.width = i;
                          document.getElementById('Directory1').style.width = i;
                          document.getElementById('Directory2').style.width = i;
                          document.getElementById('Directory3').style.width = i;
                          i-=1;
                          }
    	
    function Display(a){
                               Hide(1,4);
    			if(i>=110){
                               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'; 
                                               b++;
                                               }
                              }
    
    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

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    http://www.w3.org/TR/xhtml1/#h-4.8
    Last edited by Roy Sinclair; 03-16-2004 at 02:32 PM.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no, no, the page DOES validate, but my script does NOT work in a strict doctype

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    got the site up, please ignore the add , anyways if u save the page and add a strick doctype then it wont work

    http://www34.brinkster.com/dgothe/db/

    or attachment
    Attached Files Attached Files

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #9
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but the rightclick script still dosnt work

  • #10
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    about jslint...
    Why does it consider ++ as harmfull?
    And also, how can I rapidly find character 105...
    Shawn

  • #11
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by JAVAEOC
    but the rightclick script still dosnt work
    It does for me (after I push the "Enable Right Click" button).
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #13
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Roy even after u added a strick doctype?

  • #14
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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
    Shawn

  • #15
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    Last edited by Roy Sinclair; 03-27-2004 at 03:45 PM.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •