Position of cursor in WKWebView with an editable paragraph in iOS Position of cursor in WKWebView with an editable paragraph in iOS javascript javascript

Position of cursor in WKWebView with an editable paragraph in iOS


If you have access to document and mouse position inside the view you can use document.elementFromPoint(x, y);


This can be done in multiple ways using HTML5 (using autofocus atribute) or using javascript (document.getElementById("IDHERE").focus(); - using focus event). I will write all in one code snippet uncomment and use it based on your requirement.

//if u commnet the second form let domObject =  document.getElementById("lname"); // refer which object to focusdomObject.focus(); // event to trigger focus on the refereced dom object  //throw error till second form is uncommented
<!-- html5 way the most easiest way --><form action="/action_page.php">  First name: <input type="text" name="fname"><br>  Last name: <input type="text" name="lname" autofocus><br>  <input type="submit"></form><!-- autofocus refers where to focus --><!-- unncoment below and comment above --><!-- javascript way --><!-- <form action="/action_page.php">  First name: <input type="text" id="fname"><br>  Last name: <input type="text" id="lname"><br>  <input type="submit"></form>-->