iOS - When using WKWebView, OC calls the user-select attribute of JS to control user operations

 

// Called after the page is loaded

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation {

    // Do not execute the JS code of the pop-up list in the previous interface

    [webView evaluateJavaScript:@"document.documentElement.style.webkitTouchCallout='none';" completionHandler:nil];

    [webView evaluateJavaScript:@"document.documentElement.style.webkitUserSelect='none'" completionHandler:nil];

   

}

 

The user-select attribute is used to prohibit users from selecting text, pictures, etc. on the page with the mouse, that is, to make the content of the page unselectable. It is also possible to only allow the user to select the text, or to release all of them, and the user can select the text at the same time, as well as other things such as pictures and videos in the text. The role of the user-select attribute is at the element level. It can not only affect the entire page, but also only take effect on the specified element and its child elements.

At present, various browser engine prefixes are used , and its role can still be played well.

Let's first look at the syntax of the user-select attribute:

user-select: none;
user-select: auto;
user-select: text;
user-select: contain;
user-select: all;
//火狐浏览器
-moz-user-select: none;
-moz-user-select: text;
-moz-user-select: all;
//谷歌浏览器
-webkit-user-select: none;
-webkit-user-select: text;
-webkit-user-select: all;
//IE
-ms-user-select: none;
-ms-user-select: text;
-ms-user-select: all;
-ms-user-select: element;

 

 

The following is an introduction to the attribute value of the "user-select" attribute:

 

none
Disable user selection
text
No restrictions on user choices
all
The target element will be selected as a whole, that is to say, only part of it cannot be selected. When you select part of the text with the mouse, the browser will automatically select the content in the entire element.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324470919&siteId=291194637