Home > Mac > Change selection in Safari via JavaScript

Change selection in Safari via JavaScript

It’s easy to get the current selection with Javascript. It’s easy to select an entire node.

But what if you want to create a selection that spans multiple elements?

Easy (after a few hours of bumbling around, lol):

  1. Select the text in the element where you want the block to start (I used window.find())
  2. Save the start point in a range object with setStart
  3. Repeat 1 & 2 with the end point, setting the end of the range object
  4. Select the (multi-node) range object you just created with window.getSelection().addRange()

Get the code here.

Enjoy!

Categories: Mac Tags: ,

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip
\n