1

According to an answer to this question, it is technically very difficult to create selection ranges from the user's mouse position. Why is this? How is it that selections can be created from the mouse position in the browser normally, but creating the same range using JavaScript is difficult?

Community
  • 1
  • 1
Vardarac
  • 563
  • 2
  • 17

1 Answers1

2

Because the browser can use whatever native OS methods it wants because it only has to work within it's own environment. Your Javascript code on the other hand is constrained by the functionality the browser decided to expose to external (i.e. your) code. This is usually constrained to what's in the published standards (give or take a little...or sometimes a lot). Your code needs to run everywhere, all browsers, all OS's, all devices. The browser code only needs to run on one OS, and often on a small subset of devices.

But - you might say - I can run Chrome, or Safari, or Firefox on different OS's and different devices. Yes, you can, but it's not the same code. They are different versions of the browser optimized for each environment. They may share a lot of code, but they also have significant differences, especially the parts that interact directly with the underlying OS.

Matt Burland
  • 44,552
  • 18
  • 99
  • 171