JS error in ie7,8 and 5?

415 views Asked by At

I am using IE Tester and this code is not working in IE5, IE7 and IE8, Please give me a solution

<html>
    <head>
        <title>IE Tester</title>
        <script type="text/javascript">
            function functions(data){
                alert(data);
            }
        </script>        
    </head>
    <body>
        <input type="button" value="btn1" onclick="javascript:functions('<?php echo "add_new";?>');"/>
        <input type="button" value="btn2" onclick="javascript:functions('a');"/>
        <input type="button" value="btn3" onclick="functions('a');"/>
    </body>
</html>
3

There are 3 answers

0
sstendal On

The javascript is correct, so if none of the buttons are working then the likely reason is that you have de-activated javascript in your browser.

2
Encore PTL On

Make sure you escape the quotations in the input onclick event using backslash \"

<input type="button" value="btn1" onclick="javascript:functions('<?php echo \"add_new\";?>');"/>
0
Chris Gessler On

I just tested the following PHP output in IE8 and it works fine. I'd say you may have found a bug in IETester. But, you might want to remove the "javascript:" part just to see if that helps. Edit: This forum might help as well, it looks like the bug has been reported before.

<html>     
  <head>         
    <title>IE Tester</title>         
    <script type="text/javascript">             
      function functions(data){                 
        alert(data);             
      }         
    </script>             
  </head>     
  <body>         
    <input type="button" value="btn1" onclick="javascript:functions('add_new');"/>         
    <input type="button" value="btn2" onclick="javascript:functions('a');"/>         
    <input type="button" value="btn3" onclick="functions('a');"/>     
  </body> 
</html

FYI... I used CodePad to generate the PHP output, then tested with jsFiddle