Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UIWebview将URL数据传递给Javascript_Javascript_Ios_Iframe_Uiwebview - Fatal编程技术网

UIWebview将URL数据传递给Javascript

UIWebview将URL数据传递给Javascript,javascript,ios,iframe,uiwebview,Javascript,Ios,Iframe,Uiwebview,我在向javascript传递url时遇到了一个小问题 这是一个javascript文件 function geturl(getdata) { document.getElementById('test001').src = getdata;//Iframe don't display data.but if I put url like 'http://stackoverflow.com/questions/ask' is will work. } window.onlo

我在向javascript传递url时遇到了一个小问题

这是一个javascript文件

function geturl(getdata) {

     document.getElementById('test001').src =   getdata;//Iframe don't display data.but if I put url like 'http://stackoverflow.com/questions/ask'  is will work. 

}
window.onload = function ()
{
    geturl();
}
和Obj-C

 NSString * getdata  = @"de";

[subView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"geturl('%@')",[getdata stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];

NSLog(@" getdata = %@",getdata);";
和Iframe

<iframe id="test001" src="" frameborder="0" hspace="0"  ></iframe>

如何在Iframe上使用从Obj-c到javascript的url。谢谢你的建议


更新

我尝试在getdata中显示数据 如果I
alert(getdata)
显示正确的数据。
但是如果我使用这个
document.getElementById('test001').src='1〕http://en.wikipedia.org/wiki/“+getdata获取数据将显示未定义:
http://en.wikipedia.org/wiki/undefined
类似这样的内容。问题来自IOS或javascript,请通知我。

来自[NSString stringWithFormat:@“geturl(%@)”,[getdata stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]的输出

将是

“geturl()”

需要的时候

geturl(“”)

尝试将格式字符串更改为


@“geturl('%@')”

此外,您可能希望尝试在标准浏览器中调试它。如果我在chrome中使用该url,我会看到错误“拒绝在框架中显示“”,因为它将“X-frame-Options”设置为“SAMEORIGIN”。“请尝试使用其他url(指向不阻止在框架中显示自身的页面)。