window.location在objective-c中的jquery文件中显示jquery文件位置而不是window.location参数

时间:2012-05-17 03:37:06

标签: jquery objective-c xcode uiwebview

在jQuery文件中:

this.item_test = function(){
    $('body').css('background-color', '#00ff00');
    window.location = "/allCorrect/yes";
}

Out come 1(第1行证明jQuery正在运行): UIWebView颜色的背景为绿色(预期和正确)。

Out out 2(对于第2行,window.location行):(UIWebView *)webView shouldStartLoadWithRequest:委托方法中,request.mainDocumentURL.relativePath的预期值为/allCorrect/yes

我的问题: 而不是得到“/ allCorrect / yes”,我得到调用jQuery文件本身的以下文件位置:

“/ Users / chiemekailo / Library / Application Support / iPhone Simulator / 5.0 / Applications / 77BB3C4A-E99C-47C3-B2AE-F4DSDMFE84MFOEF / Documents / Unzipped / OPS”

1 个答案:

答案 0 :(得分:0)

这可以在不使用jQuery的情况下工作,所以我无法想象jQuery为什么或如何有所作为,但不是使用位置更改,而是可以尝试使用此方法,而不使用jQuery也会触发webViewShouldStartLoadWithRequest以查看它是否有效用jQuery。

iFrame = document.createElement("IFRAME");
iFrame.setAttribute("src", "/allcorrect/yes");
document.body.appendChild(iFrame); 
iFrame.parentNode.removeChild(iFrame);
iFrame = null;