eval function not working in Mozilla

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • makthar
    New Member
    • Aug 2007
    • 13

    eval function not working in Mozilla

    Hi

    My second question is the eval function of javascript works fine in IE7 but not in Mozilla. The function in my code is as follows:
    Code:
    var str = "alert('how r u')";
    eval(str);
    How do i make it work in Mozilla.

    Thanks
    Mansoor
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Mansoor.

    Are you getting an error, or is it just not doing anything?

    Comment

    • makthar
      New Member
      • Aug 2007
      • 13

      #3
      Hi
      Thanks for the reply.

      But i donot know how to check for errors in mozilla, and also nothing is showing up

      Thanks
      Mansoor

      Comment

      • makthar
        New Member
        • Aug 2007
        • 13

        #4
        Hi
        browse http://www.w3schools.c om/js/tryit.asp?filen ame=tryjs_text
        and remove the code on the left hand side and paste the following code and test it


        Code:
        <html>
        <head>
        <script type="text/javascript">
        function valuereturned()
        {
        
        var str="alert('button has been clicked')";
        return str;
        }
        function evaluate()
        {
        str2= valuereturned();
        eval(str2);
        }
        
        </script>
        </head>
        <body>
        <input type="button" value ="Click Me" onClick="evaluate()">
        
        </body>
        </html>
        This works fine when the link pasted above is opened in IE7 but doesnot seem to work in Mozilla
        Thanks
        Mansoor

        Comment

        Working...