0

html代码:

<head id="Head1" runat="server">
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <title>Search</title>
</head>

<form id="form1" runat="server">

<div>
    <input type="text" id="userurlbox"/>
    <input type="button" value="Open" onclick="myFunction()"/>

</div>

</form>

脚本 :

<script type="text/javascript">
function myFunction() {
        var x = document.getElementById('userurlbox').value;
        if(x==0){           

            alert('Please enter a URL');
        }

        else {
            if (x.indexOf("http://")!=-1 || x.indexOf("https://") != -1 && x.indexOf(".edu") != -1) {
                window.open(x);
            }
            else if (x.indexOf("http://")==-1 || x.indexOf("https://") == -1 && x.indexOf(".edu") != -1) {
                if(x.indexOf("http://")==-1){
                window.open("http://" + x);
                }
            else {
                window.open("https://"+x);
                }
            }
            else {
                window.open("http://www.google.com/search?q=" + x);
            }
        }
    }
</script>

当我输入网址为“www.badmintonchennai.com”时,我收到了这个“延迟加载”错误。

我尝试了“www.karunya.edu” Microsoft Run time error, $ undefined,在 IE9 中我收到以下错误为“”,但在 Firefox 中我没有收到此错误。

我还尝试了许多其他工作正常的网站。

为什么这些特定的网站会出现错误?以及如何解决它们。

4

1 回答 1

0

I don't have problems with your code, i Just make an html with your code, and works fine.

    <html>
    <head></head>
    <head id="Head1" runat="server">
        <script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js" type="text/javascript"></script>
        <title>Search</title>
    </head>

    <body>
    <form id="form1" runat="server">

    <div>
        <input type="text" id="userurlbox"/>
        <input type="button" value="Open" onclick="myFunction()"/>

    </div>

    </form>


    </body>
<script type="text/javascript">
    function myFunction() {
            var x = document.getElementById('userurlbox').value;
            if(x==0){           

                alert('Please enter a URL');
            }

            else {
                if (x.indexOf("http://")!=-1 || x.indexOf("https://") != -1 && x.indexOf(".edu") != -1) {
                    window.open(x);
                }
                else if (x.indexOf("http://")==-1 || x.indexOf("https://") == -1 && x.indexOf(".edu") != -1) {
                    if(x.indexOf("http://")==-1){
                    window.open("http://" + x);
                    }
                else {
                    window.open("https://"+x);
                    }
                }
                else {
                    window.open("http://www.google.com/search?q=" + x);
                }
            }
        }
    </script>

    </html>
于 2013-05-29T08:34:06.187 回答