-1

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>
Karandeep Singh
  • 1,223
  • 5
  • 22
  • 34
  • 2
    How is it not working? What are the symptoms? – Gumbo Mar 25 '12 at 16:34
  • @KarandeepSingh Can you show the rendered HTML? – Rob W Mar 25 '12 at 16:40
  • @RobW: if I wrote 'document.write(data)' then its working but alert is nor working here. – Karandeep Singh Mar 25 '12 at 16:45
  • @KarandeepSingh _HOW_ is it not working? Your title says you get an error, so, which error? – Mr Lister Mar 25 '12 at 16:53
  • 2
    Why do you care about Explorer 5 ? – Sparky Mar 25 '12 at 17:01
  • @MrLister: error is thatc ==> alert box not showing – Karandeep Singh Mar 25 '12 at 17:08
  • @Sparky672 - the op probably doesn't care about IE5, but cares more that it works in IETester across all IE versions it supports which is 5.5 - 9. – Chris Gessler Mar 25 '12 at 17:09
  • 2
    I don't use IETester because you'll just never know for sure if you have a IE issue or an IETester issue. I use the free [MS Virtual PC](http://www.microsoft.com/windows/virtual-pc/default.aspx) and the [free Hard Drive images provided by MS](http://www.microsoft.com/download/en/details.aspx?id=11575) for testing websites in IE versions 6 through 9. – Sparky Mar 25 '12 at 17:50

3 Answers3

1

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

Chris Gessler
  • 22,727
  • 7
  • 57
  • 83
0

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.

sstendal
  • 3,148
  • 17
  • 22
-1

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\";?>');"/>
Encore PTL
  • 8,084
  • 10
  • 43
  • 78