The H5 page in WebView that encounters iOS on the job needs to be transparent to show the webview background color. With H5 own transparency CSS style or JS control background color and transparency can not hit the desired effect, and finally through the iOS set WebView body color and transparency to achieve, the specific code is as follows:
-(void) Webviewdidfinishload: (UIWebView *) webview{ [WebView Stringbyevaluatingjavascriptfromstring:@ "document.getelementsbytagname (' body ') [0]. Style.background= ' Rgba (0,0,0,0) '"];}
The H5 page is then transparent and displays the WebView background color. Android has not yet researched how to set the background of the H5 page in WebView. There is time to study it later.
Incidentally, the way iOS calls the foreground page JS method:
First, you add a JS method to the page and return a value, for example:
//See more iOS call MethodsfunctionGetparameterforios (parameter) {varResult= ""; varCity=sessionstorage.getitem ("usedCarCity001"); varIs_type=sessionstorage.getitem ("usedCarCertification002"); if(is_type== "true") {Is_type= 0; }Else{Is_type= 1; } // City if(parameter== "City") {result=City ; } //Is_type if(parameter== "Certification") {result=Is_type; } returnresult;}
Then, in iOS, the method is called when the webview load starts or ends, for example:
-(void) Webviewdidstartload: (UIWebView *) webview{ *certification = [WebView Stringbyevaluatingjavascriptfromstring:@ "getparameterforios (' certification ')"]; }
The resulting return value is assigned to the variable for use.
Big God do not spray, younger brother just encounter this problem, do a record only ...
iOS modifies WebView background transparency and iOS calling the foreground JS method