Hi guys,
I've written a simple test with rangy's selection save/restore
function:
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head>
<title>Hello</title>
<script type="text/javascript" src="rangy-core.js"></script>
<script type="text/javascript" src="rangy-
selectionsaverestore.js"></script>
</head>
<body>
<div id="show" class="code" contenteditable="true"><span
style="color:red">12345</span>12345</div>
<script type="text/javascript">
window.setTimeout(function () {
var s = rangy.saveSelection();
var show = document.getElementById("show");
show.innerHTML = "1234512345";
rangy.restoreSelection(s);
}, 5000)
</script>
</body>
</html>
Basicly I have a div with colored text, and at some time I want to
replace the content with plain text (or some other html structure with
the same text). I used the code above to text the scenario but find
there's an error said: "Rangy warning: Module SaveRestore: Marker
element has been removed. Cannot restore selection."
Does rangy support the feature I mentioned above? If yes, how should I
use it? If no, what should I do to implement that?
Thanks.
- Jeff