It's a followup question of this. I've serialized the selection of text in an iframe and want to restore it but it gives me an error, "Uncaught Error: deserializeRange: checksums of serialized range root node (XXXXX) and target root node (XXXXX) do not match"
var iframe = $("iframe")[0];
var selection = rangy.getSelection(iframe);
var serializeSelection = rangy.serializeSelection(selection);
alert(serializeSelection);
rangy.deserializeSelection(serializeSelection);
You need to provide the window object as the third parameter:
rangy.deserializeSelection(serializeSelection, null, iframe.contentWindow);
Demo: http://jsfiddle.net/2d6Bk/2/
This is more awkward than it should be. Version 1.3 allows you to use iframe
rather than iframe.contentWindow
, but it's still too unreadable so I will improve this somehow.