2011-10-19 12 views
1

uiwebviewのスクリプトをURLとしてロードする方法は?スクリプトをUIWebView url

私はこれ試してみてください。

-(IBAction)rulButtonPressed:(id)sender{ 
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"#1 onclick=s=document.createElement('script');s.src='http://sidio.ru/rul/last30.js.php?'+Math.random();document.body.appendChild(s);"]]]; 

} 

が、その、今、私は質問は少しあいまいですが、あなたはおそらく使用したいボタン

答えて

1

を押した後、URLとしてそれをロードする必要が

作業をこれらの1:

[_webView stringByEvaluatingJavaScriptFromString:(NSString *)]; 
[_webView loadHTMLString:(NSString *) baseURL:(NSURL *)]; 

UIWebView Docs
UIWebViewDelegate Protocol Docs


このような何かあなたのために働くかもしれない:

- (IBAction)rulButtonPressed:(id)sender { 
    [_webView stringByEvaluatingJavaScriptFromString:@"document.createElement('script');s.src='http://sidio.ru/rul/last30.js.php?'+Math.random();document.body.appendChild(s);"]; 
} 
+0

[OK]を、私はこのJavaScriptをロードする必要がありますのonclick = S =のdocument.createElement( 'スクリプト'); s.src =」 http://sidio.ru/rul/last30.js.php?'+Math.random();document.body.appendChild(s);私はボタンrulButtonPressedをタップしたとき – nik1004

+0

あなたは多分 ' - (IBAction)rulButtonPressed:(id)sender {[_webView stringByEvaluatingJavaScriptFromString:@" document.createElement( 'script'); s.src = 'http: /sidio.ru/rul/last30.js.php?'+Math.random();document.body.appendChild(s); "]; } ' – chown

+0

ありがとうございました!今はその作品!) – nik1004

関連する問題