Browser selections

hh hh at hyperhh.de
Mon Apr 8 07:22:09 EDT 2019


(Getting the selection of a browser widget: Aee my previous post).

Setting the selection of a browser widget:

Assume you have an element <a id='jlg1'>click me</a> in your webpage.
Then the following selects char 1 to 4 of the link text (= "clic").

on mouseUp
  put "var node = document.getElementById('jlg1').firstChild;" & \
        "var range = document.createRange();" & \
        "range.setStart(node, 0); range.setEnd(node, 3);" & \
        "var selection = window.getSelection();" & \
        "selection.removeAllRanges(); selection.addRange(range);" into js
  do js in widget "Browser"
end mouseUp

Note that setStart and setEnd are zero-based in counting chars.





More information about the use-livecode mailing list