HTTP-EQUIV="REFRESH" conflict with window.location
HTTP-EQUIV="REFRESH" conflict with window.location = url
我使用以下javascript来处理UIWebView中的"页面加载"事件:
(function() {
if (typeof Browser == "undefined") {
Browser = {};
}
var onWindowLoaded = function() {
Browser.commands.sendCommand("page-loaded");
};
if (document.readyState === "complete") {
onWindowLoaded();
}
else {
window.addEventListener('loaded', function(event) {
onWindowLoaded();
});
}
})();
我用stringByEvaluatingJavaScriptFromString:
加载它
sendCommand 函数调用window.location = url;
(具有特定方案的 url,使我有可能处理事件)
所以一切都很好,除了一页:online.rsb.ru
UIWebView
显示空白页
开始用curl分析那个页面,我得到的是:
获取网址 online.rsb.ru
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Fri, 13 Sep 2013 08:34:32 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://online.rsb.ru//
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 13 Sep 2013 08:34:33 GMT
Content-Type: text/html
Content-Length: 125
Last-Modified: Tue, 29 Jun 2010 06:59:42 GMT
Connection: keep-alive
Set-Cookie: i=wkMdtFIyzhljiGI7BEXfAg==; expires=Sat, 13-Sep-14 08:34:33 GMT; domain=online.rsb.ru; path=/
P3P: policyref="/w3c/p3p.xml", CP="CUR ADM OUR NOR STA NID"
Accept-Ranges: bytes
<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=https://online.rsb.ru/hb/">
<title></title>
</head>
</body>
</html>
获取网址 https://online.rsb.ru/hb/
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 13 Sep 2013 08:36:18 GMT
Content-Type: text/html
Connection: keep-alive
Last-Modified: Wed, 11 Sep 2013 12:50:56 GMT
Accept-Ranges: bytes
Content-Length: 152
Set-Cookie: i=wkMdulIyzoJJM3O1BB1nAg==; expires=Sat, 13-Sep-14 08:36:18 GMT; domain=online.rsb.ru; path=/
P3P: policyref="/w3c/p3p.xml", CP="CUR ADM OUR NOR STA NID"
<html>
<head>
<script type="text/javascript">
window.location = "faces/system/login/rslogin.jsp?credit=false"
</script>
</head>
</html>
所以,我发现我的javascript可能会与下一行代码冲突:
<meta HTTP-EQUIV="REFRESH" content="0; url=https://online.rsb.ru/hb/">
或与
window.location = "faces/system/login/rslogin.jsp?credit=false"
(问题取决于我的 JavaScript,如果我删除stringByEvaluatingJavaScriptFromString:
页面加载正常的调用)
有人可以给我建议,我怎样才能避免这种冲突?谢谢!
问题已解决:
我已经在我的脚本中替换了 window.location = url; 的执行使用以下代码
function sendURLToUIWebView(url) {
var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", url);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
}
相关文章:
如何从Javascript调用Objective-C?
http://blog.techno-barje.fr/post/2010/10/06/UIWebView-secrets-part3-How-to-properly-call-ObjectiveC-from-Javascript/
相关文章:
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "可以't查找变量:window“;在suds.js中
- "event=event|window.event”;找不到成员.RequiredFieldValidator
- 为什么"这个“;指的是javascript中forEach中的Window
- 什么是“-[1;平均值;if(!-[1,]&&!window.XMLHttpRequest)"
- window.safari.pushNotification.requestPermission总是返回"拒绝
- 如何在HTML、JS中重定向,如果用户关闭“;window.open()"-对话
- 这里有一种新型的广告javascript通过change"window.opener.location”;,我
- 为什么<车身负载=“;fn()">使用函数调用,但是window.onload=fn;使用处理程序函
- window.open()添加一个rel="nofollow”;属性
- 为什么“;window=window.parent"创建一个无限循环
- "闭合的“;属性异常返回“;window.open”;在JavaScript&歌剧
- jQuery替换所有href=""其中onclick=“;window.location=“;
- 需要HTML表单检查=“"在onclick=“;window.print()”;
- 命令“;window.location.href"不适用于HTML(引导框架)
- <a href="javascript:foo(this)">通过Window,我想要标记
- 可以't添加<script src=“"到使用Window.open().docent.writ
- Webkit通知中的JavaScript window.open()(和<a href="#"
- javascript:<车身负载=“">和window.onload
- 为什么href="javascript:window.location.href='#xxx'&q