Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

javascript - Does chrome supports document.selection?

I am new to javascript, trying to perform:

document.selection.createRange();

but document.selection always returns undefined.

I am using latest version of chrome.

what am I doing wrong?

thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use window.getSelection(), which is the most cross-browser compatible (it's supported in the current versions of all major browsers) and is the standard. Chrome certainly supports it as fully as other browsers.

document.selection should only be used for IE < 9.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...