Connecting Tech Pros Worldwide Help | Site Map

Javascript not working with XHTML DTD

Member
 
Join Date: Nov 2008
Posts: 41
#1: Sep 8 '09
wrote a javascript and it never worked until i removed the
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
i thought this is a standard and wonder why i have to remove it before mycode will work
am using dreamweaver 8
any help?
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#2: Sep 8 '09

re: Javascript not working with XHTML DTD


the only problem I ever had with Javascript and a XHTML DTD is that Firebug complains about a missing semi-colon (which doesn’t make sense and I always can safely ignore this error)

btw. is it not working in dreamweaver or not working in the browser?
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 348
#3: Sep 8 '09

re: Javascript not working with XHTML DTD


Are you using any JS Framework with your code.. like ExtJS or Jquery?

Thanks and Regards
Ramanan Kalirajan
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Sep 8 '09

re: Javascript not working with XHTML DTD


For any new pages, you should be using strict except in a few cases. Also, are you really using XHTML or HTML? Post your JavaScript code or explain what was not working.
Member
 
Join Date: Nov 2008
Posts: 41
#5: Sep 9 '09

re: Javascript not working with XHTML DTD


Expand|Select|Wrap|Line Numbers
  1. function show(menu){
  2.    if(menu.style.display="none"){
  3.        menu.style.display="";
  4.    }else{
  5.             menu.style.display="none";
  6.           }
  7. }
  8.  
i dont think there is anything special here
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#6: Sep 9 '09

re: Javascript not working with XHTML DTD


Quote:

Originally Posted by freefony View Post

Expand|Select|Wrap|Line Numbers
  1.    if(menu.style.display="none"){

is the assignment here intended?
Member
 
Join Date: Nov 2008
Posts: 41
#7: Sep 9 '09

re: Javascript not working with XHTML DTD


yes i want the display to be none on page load is there a better way?
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#8: Sep 9 '09

re: Javascript not working with XHTML DTD


use the window.onload event or a CSS default value.

Expand|Select|Wrap|Line Numbers
  1. menu.style.display="";
is not valid CSS. should be one of "block", "inline", "inline-block", … but certainly not "".

your show() function will always set the display style to "", no matter which value it had before.
Member
 
Join Date: Nov 2008
Posts: 41
#9: Sep 9 '09

re: Javascript not working with XHTML DTD


thanks for that it helps . but please if u do php what is the javascricpt equivelent for ? and | location am working on a frameset with 3 windows 1search window 2.design window and 3. result window . something like this
Expand|Select|Wrap|Line Numbers
  1. var regno= this.document.forms[0].reg.value;
  2. <input type="button" id="regno" onclick="result.src='result.php?regno=regno'"/> 
  3.  
the src of the result window is dynamic and can display other documents
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#10: Sep 9 '09

re: Javascript not working with XHTML DTD


Quote:

Originally Posted by freefony View Post

but please if u do php what is the javascricpt equivelent for ? and | location

what is that supposed to mean?
Member
 
Join Date: Nov 2008
Posts: 41
#11: Sep 9 '09

re: Javascript not working with XHTML DTD


in php i will do this when the button is click
Expand|Select|Wrap|Line Numbers
  1. header("location:result.php?regno=$regno");
  2.  
but i want javascript to do this with an onclick event of a button
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#12: Sep 9 '09

re: Javascript not working with XHTML DTD


use location.href

___
Reply