我正在使用PhoneGap编写iPad应用程序,我想加载外部URL而不触发Safari或使用像ChildBrowser这样的内部Web浏览器.
我正在使用PhoneGap iPad/iPhone示例项目,我尝试了不同的方法.在onBodyLoad()函数中,我添加了:
window.location.href('http://www.wordreference.com');
Run Code Online (Sandbox Code Playgroud)
但是这一行使用一个新的Safari窗口打开链接.从那时起,无法返回PhoneGap
之后,我尝试使用document.write替换页面内容的AJAX请求
function loadHTML(url, timeout) {
if (timeout == undefined)
timeout = 10000;
var req = new XMLHttpRequest();
var timer = setTimeout(function() {
try {
req.abort();
} catch(e) {}
navigator.notification.loadingStop();
},timeout);
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status < 300) {
clearTimeout(timer);
var html = req.responseText;
//just a debug print
alert(html);
document.write(html);
}
navigator.notification.loadingStop();
delete req;
}
};
req.open('GET', url, true);
req.send();
}
Run Code Online (Sandbox Code Playgroud)
现在,从onBodyLoad()内部调用:
loadHTML('http://www.wordreference.com',10000);
Run Code Online (Sandbox Code Playgroud)
打开PhoneGap容器中的链接,没问题.关键是我想加载用Python编写的动态页面
loadHTML('http://www.mysite.com/cgi-bin/index.py',10000)
Run Code Online (Sandbox Code Playgroud)
此时未调用Safari,但会显示PhoneGap容器中的黑色页面!我想指出,如果我在Safari中键入它,链接就完全正常工作(我无法报告隐私问题).
可能是与某种必要的许可有关的问题???
我找到了与PhoneGap for …
当我尝试使用PhoneGap的Socket.IO时,我收到此错误:
(在iOS上应该支持socket.io)
Access-Control-Allow-Origin不允许使用null.
这是因为我的应用程序是通过file://协议提供的.我该怎么做才能解决这个问题?
谢谢!!
我有一个node.js服务器启动并运行Express,我正在尝试使用socket.io服务器端和chrome 12客户端建立websocket连接.当我尝试连接时,socket.io输出一条调试消息,说"破坏nonsocket.io升级",并且我的连接处理程序中的代码不运行.同样在客户端,我的socket的readyState是2(CLOSING).
[edit]套接字的readyState从0更改为2