I apologize for the interruption. However, seabreezecomputers.com has been offering free tools and downloads for many years. Unfortunately, server expenses are now starting to exceed revenue earned. If you appreciate the free tools and downloads at seabreezcomputers.com please consider making a donation. If everyone who visited this website donated just $1.00 then we could end this campaign in 1 week! Thank you to all those who have donated.
I have created serialize/deserialize functions for Rangy that gives the same serialization between IE <= 8, IE 9, Webkit (Chrome, Safari, iPhone) and Firefox. It seems to work in the testing I have done. The two functions have comments explaining what they do. You can serialize a range in IE and it should be able to deserialize in Chrome, etc. It has worked so far in multiple pages that I have tested.
The functions count through all elements on the page or in the rootNode provided and skips the elements that are not compatible between the browsers or that have an emtpy innerHTML. The incompatible elements are title tags and comment tags and some tags with empty innerHTML.
The serialized range that is returned is seperated by commas and contains this data: startCharacter, endCharacter, startElement, endElement, startTextNode, endTextNode. So 0,26,333,333,0,0 would be the 0th or 1st character hightlighted to the 26th character highlighted, in the 333 HTML element (not counting incompatible elements) starting and ending in the first text node in the element (or text node 0). dlc_b
Downloaded 0 times.
Please make a donation to reveal the download link.
Use as follows:
cb_serializeRange(Range range[,Element rootNode])
selection = rangy.getSelection(); if(selection.rangeCount > 0) range = selection.getRangeAt(0); var serial = cb_serializeRange(range, document.getElementById('container'));
will return a serial of the range starting from the 'container' element.
cb_deserializeRange(String cb_serializedRange[, Element rootNode])
range = cb_deserializeRange("0,26,333,333,0,0", document.getElementById('container'))
will return a rangy range based on the serial provided starting from the 'container' element.