Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it correct to invoke stringByEvaluatingJavaScriptFromString of UIWebView in viewDidLoad?

I need to set the background of webView at a time when the html has not loaded.

In iOS 5.0 this code is correctly working:

- (void)viewDidLoad
{
    [super viewDidLoad];
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.backgroundColor=\"#41414C\";"];
}

But in iOS 4.2 nothing happening with background.

How can I set background of web View at a time when the html has not loaded?

like image 669
BergP Avatar asked Jun 07 '26 04:06

BergP


1 Answers

In my case I used webview:webViewDidFinishLoad method to evaluate javascript. It was working correctly in 4.2 but since I haven't tested it in iOS 5, I am not sure about its working in that version.

like image 77
Naved Avatar answered Jun 10 '26 16:06

Naved