gpt4 book ai didi

javascript - 删除显示 HTML 字符的 elementFromPoint()

转载 作者:行者123 更新时间:2023-11-28 08:49:03 24 4
gpt4 key购买 nike

我需要从 UIWebView 中选择一些文本。我引用了这个答案Getting selected elements programatically from uiwebview?但是当我使用点击它选择文本时。但它还显示所有 HTML 字符Selected Name: 1      仪器名称

-(void)singleTap:(UIGestureRecognizer *)gestureRecognizer
{

NSLog(@"single tap");

CGPoint touchPoint = [gestureRecognizer locationInView:wbCont];

//NSString *js = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).toString()", touchPoint.x, touchPoint.y];

NSString *js = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).innerHTML", touchPoint.x, touchPoint.y];

NSString * tagName = [wbCont stringByEvaluatingJavaScriptFromString:js];

NSLog(@"Selected Name: %@",tagName);

}

最佳答案

我从 stringByReplacingOccurrencesOfString: 函数得到答案。我使用了下面的代码。运行良好。

tagName=[tagName stringByReplacingOccurrencesOfString:@" " withString:@""];

关于javascript - 删除显示 HTML 字符的 elementFromPoint(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19374932/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com