Javascript not working with XHTML DTD

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freefony
    New Member
    • Nov 2008
    • 59

    Javascript not working with XHTML DTD

    wrote a javascript and it never worked until i removed the
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "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?
    Last edited by Dormilich; Sep 8 '09, 12:25 PM. Reason: changed title
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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?

    Comment

    • RamananKalirajan
      Contributor
      • Mar 2008
      • 608

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

      Thanks and Regards
      Ramanan Kalirajan

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        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.

        Comment

        • freefony
          New Member
          • Nov 2008
          • 59

          #5
          this is my javavscript

          Code:
          function show(menu){
             if(menu.style.display="none"){
                 menu.style.display="";
             }else{
                      menu.style.display="none";
                    }
          }
          i dont think there is anything special here

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            Originally posted by freefony
            Code:
               if(menu.style.display="none"){
            is the assignment here intended?

            Comment

            • freefony
              New Member
              • Nov 2008
              • 59

              #7
              yes

              yes i want the display to be none on page load is there a better way?

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

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

                Code:
                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.

                Comment

                • freefony
                  New Member
                  • Nov 2008
                  • 59

                  #9
                  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
                  Code:
                  var regno= this.document.forms[0].reg.value;
                  <input type="button" id="regno" onclick="result.src='result.php?regno=regno'"/>
                  the src of the result window is dynamic and can display other documents

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    Originally posted by freefony
                    but please if u do php what is the javascricpt equivelent for ? and | location
                    what is that supposed to mean?

                    Comment

                    • freefony
                      New Member
                      • Nov 2008
                      • 59

                      #11
                      in php i will do this when the button is click
                      Code:
                      header("location:result.php?regno=$regno");
                      but i want javascript to do this with an onclick event of a button

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        use location.href

                        ___

                        Comment

                        Working...