0

我在我的 UIWebView 中嵌入了 phoneGap,参考了这个文档: http ://docs.phonegap.com/en/2.2.0/guide_cordova-webview_ios.md.html#Embedding%20Cordova%20WebView%20on%20iOS

在 index.html 中,我编写了以下示例代码:

<html>
<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

    <script>

        $(document).ready(function() {
                          alert(“jquery loaded”);
                          });
    </script>
</head>

<body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button>Click me</button>
</body>

webview加载后,可以显示“body”,但不能弹出alert。所以 jquery.js 没有加载?还是有其他问题?

编辑:我在 src 中添加了“http:”,但不起作用。

谢谢!

4

4 回答 4

1

在您的代码中添加 http 或 https

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

以上应该对你有用。

于 2013-04-03T09:35:36.367 回答
1

改变

alert(“jquery loaded”);

alert("jquery loaded");

或者

alert('jquery loaded');
于 2013-04-09T09:21:55.530 回答
0

您是否添加了 Cordova 文件?

<html>
<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="./cordova-2.3.0.js"></script>
    <script>

        $(document).ready(function() {
                          alert(“jquery loaded”);
                          });
    </script>
</head>

<body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button>Click me</button>
</body>
</html>

此外,尽管 phonegap 使用 HTML 5,但它仍然需要一些不同的代码编写风格。您创建的每个页面都应该在同一个索引页面中,因为 Cordova 在您的项目启动时加载。如果您离开页面 Cordova 需要重新加载。

于 2013-04-03T14:19:50.980 回答
-1

您是否在 www forder (www/jquery.js) 复制了 jquery 文件。我也用 jquery,我的是 www/js/jquery.js 试试这个!!!

于 2013-04-08T02:52:31.937 回答