0

此示例中的顶部按钮在 IE 8 中不起作用。底部的按钮可以。我必须添加/更改此示例以使顶部按钮也可以在 IE8 中使用?

<html ng-app>
<head>
    <script>
         function form_controller($scope) {
            $scope.my_submit = function() {
                alert("Using angular");

                document.my_form.method = document.my_form.method_x.value;
                document.my_form.action = document.my_form.action_x.value;

                alert(document.my_form.method);
                alert(document.my_form.action);
                alert("submitting");

                document.my_form.submit();
            }
        }
        function my_submit() {

            document.my_form.method = document.my_form.method_x.value;
            document.my_form.action = document.my_form.action_x.value;

            alert(document.my_form.method);
            alert(document.my_form.action);
            alert("Using normal form : submitting");

            document.my_form.submit();
            return(false);
        }
    </script>
</head>
<body>
    <form ng-controller="form_controller" name="my_form">
        <input type="button" value="testing" ng-click="my_submit()"/><br/>
        <input type="button" value="testing" onclick="my_submit()"/><br/>
        <input type="hidden" name="method_x" value="post"/>
        <input type="hidden" name="action_x" value="http://www.yahoo.com"/>
    </form>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"></script>
</body>

4

3 回答 3

0

<script>
     function form_controller($scope) {
          $scope.method_x="11";
           $scope.action_x="ewwe";


        $scope.my_submit = function() {
           $scope.method_x="dfdf";
           $scope.action_x="dfsdsddf";


        }
    }
    function my_submit() {

        document.my_form.method = document.my_form.method_x.value;
        document.my_form.action = document.my_form.action_x.value;

        alert(document.my_form.method);
        alert(document.my_form.action);
        alert("Using normal form : submitting");

        document.my_form.submit();
        return(false);
    }
</script> </head> <body>
<form ng-controller="form_controller" name="my_form">
    {{method_x}}<br>
    {{action_x}}<br>

    <input type="button" value="testing" ng-click="my_submit()"/><br/>
    <input type="button" value="testing" onclick="my_submit()"/><br/>
    <input type="hidden" ng-model="method_x" name="method_x" value="post"/>
    <input  type="hidden" ng-model="action_x" name="action_x" value="http://www.yahoo.com"/>
</form> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"></script>

于 2013-08-24T16:05:50.970 回答
0

我解决了它——我们需要顶部的文档类型声明,以及将 IE 置于兼容模式的元标记。我也放了 class="ng-app" 但我不知道这是否需要。

<!DOCTYPE html>
<html lang="en" class="ng-app" ng-app> 
  <head>
  <meta http-equiv="X-UA-Compatible" content="IE=8">
  ... rest of page 
于 2013-09-01T19:42:35.477 回答
0

试试这个代码;

<html ng-app>
<head>
    <script>
         function form_controller($scope) {
            $scope.my_submit = function() {
                alert("Using angular");

                document.my_form.method = document.my_form.method_x.value;
                document.my_form.action = document.my_form.action_x.value;

                alert(document.my_form.method);
                alert(document.my_form.action);
                alert("submitting");

                document.my_form.submit();
            }
        }
        function my_submit() {

            document.my_form.method = document.my_form.method_x.value;
            document.my_form.action = document.my_form.action_x.value;

            alert(document.my_form.method);
            alert(document.my_form.action);
            alert("Using normal form : submitting");

            document.my_form.submit();
            return(false);
        }
    </script>
</head>
<body>
    <form ng-controller="form_controller" name="my_form" ng-click="my_submit()">
        <input type="submit" value="testing"/><br/>
        <input type="button" value="testing" onclick="my_submit()"/><br/>
        <input type="hidden" name="method_x" value="post"/>
        <input type="hidden" name="action_x" value="http://www.yahoo.com"/>
    </form>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"></script>
</body>
于 2013-08-24T18:08:21.937 回答