[英]How to add a JavaScript code in xcode so that i can run it in webview
The ads which am integrating is from adbutler. 集成的广告来自adbutler。 The code for the ad is in javascript. 广告代码使用javascript。 i need to run the js code in UIWebview. 我需要在UIWebview中运行js代码。 Any suggestions. 有什么建议么。
The sample code is : 示例代码为:
<script type="text/javascript">
var rnd = window.rnd || Math.floor(Math.random()*10e6);
var pid156452 = window.pid156452 || rnd;
var plc156452 = window.plc156452 || 0;
var abkw = window.abkw || '';
var absrc = 'http://ab152067.adbutler-photon.com/adserve/;ID=152067;size=320x100;setID="some number";type=iframe;kw='+abkw+';pid='+pid156452+';place='+(plc156452++)+';rnd='+rnd+'';
document.write('<ifr'+'ame src="'+absrc+'" width="320" height="100" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></ifr'+'ame>');
</script>
make the code you want to run a function() in the web page. 使您想要在网页中运行function()的代码。
From iOS WebView call stringByEvaluatingJavaScriptFromString: the function 从iOS WebView调用stringByEvaluatingJavaScriptFromString:该函数
JavaScript function: JavaScript函数:
function adCrapFunction()
{
alert('Hey there buy something.');
}
iOS: iOS版:
[self.webview stringByEvaluatingJavaScriptFromString:@"adCrapFunction();"];
Some things that will get you: 一些让您满意的事情:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.