iOS gets the js corresponding element by point coordinates

Source: Internet
Author: User

A few days ago encountered problems, know the point of the screen, want to manipulate the corresponding content, record down, just a method, very superficial, deep research, there are a lot of problems to solve

   //simulate a point on the screenCGFloat x = mains.width/2, y = mains.height/2-352; //js Get point element stringNSString *JSN = [NSString stringWithFormat:@"Document.elementfrompoint (%f,%f). TagName", x, y]; //get point corresponding node element name by loading JSNSString * TagName =[_webview STRINGBYEVALUATINGJAVASCRIPTFROMSTRING:JSN]; NSLog (@"%@", TagName); //a string that gets the corresponding element and operates on itNSString * Jsee = [NSString stringWithFormat:@"var obj = document.elementfrompoint (%f,%f), alert (obj), var event = {Clientx:%f,clienty:%f};obj.click (event)", X,y,x,y]; //loading strings to achieve the effect[_webview Stringbyevaluatingjavascriptfromstring:jsee];

iOS gets the js corresponding element by point coordinates

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.