The following code gives me a really weird error in Firefox:
Error: uncaught exception: [Exception... "Index or size is negative or greater than the allowed amount" code: "1" nsresult: "0x80530001 (NS_ERROR_DOM_INDEX_SIZE_ERR)" location: "file:///G:/test.html Line: 13"]
<html>
<head>
<title>test</title>
<script>
function xxx() {
var myList = document.getElementsByTagName("div");
var range = document.createRange();
var start = myList[0];
var end = myList[0];
range.setStart(start, 1); // Edit: this is (presumably) line 13
range.setEnd(end, 3);
window.getSelection().addRange(range);
}
</script>
</head>
<body onload="xxx();">
<div>abcddasdsadasda</div>
<div>2312321</div>
</body>
</html>
What am I doing wrong?
Thank you.