У меня есть строка HTML, как показано ниже
<header><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'></header><!DOCTYPE html><html><head><style> * { word-wrap: break-word; } </style> </head> <body><div style="box-sizing: border-box; font-family: 'Segoe UI', 'Helvetica Neue', 'Apple Color Emoji', 'Segoe UI Emoji', Helvetica, Arial, sans-serif; font-size: 14px;"><div data-tid="messageBodyContainer"><div data-tid="messageBodyContent"><div>Thanks for agreeing n. I'm xyz at The and I'll serve as the moderator for the board. We'll be discussing your interactions with each other :</div><div>1) The class will be open for 2 days April 24 and April 25. Please ask questions each day, and read book.2) The approximate time commitment to the books is 30 minutes each day.</div><div></body></html>
или примерно так:
<header><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'></header><!DOCTYPE html><html><head><style> * { word-wrap: break-word; } </style> </head> <body><div><span style="font-size: 16px;"><span style="font-size: 16px; font-family: Arial;">Hello and welcome to XXXXXXX bulletin board session! </span><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</span><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span><span style="font-family: Arial;">Over the next 3 days...</span></span></div><ul> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </span> </span></li> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. </span> </span></li> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span> </span></li> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and type setting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </span> </span></li> <li><span style="font-size: 16px;"><span style="font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</span> </span></li> <li><span style="font-size: 16px; font-family: Arial;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</span></li></ul></body></html>
Теги Div или span, которые дают дополнительное пространство в wkwebview. Я хочу минимизировать пространство, которое я используюниже JavaScript, но не может удалить определенные теги, но он не работает.
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
NSString *jsCommand = [NSString stringWithFormat:
@"var element = document.getElementById('%@'); element.parentElement.removeChild(element);",
@"id2"];
[webView evaluateJavaScript:jsCommand completionHandler:^(id _Nullable stringresult, NSError * _Nullable error) {
NSLog(@"result=>%@ error->%@",stringresult,error);
}];
}
Пожалуйста, помогите