Google Группы больше не поддерживают новые публикации и подписки в сети Usenet. Опубликованный ранее контент останется доступен.

Replace range content

182 просмотра
Перейти к первому непрочитанному сообщению

homers...@gmail.com

не прочитано,
6 янв. 2007 г., 16:15:0906.01.2007
I have selection range object. Now I need to replace it contents with
my HTML code. How can I do that?

For example IE has Range.pasteHTML method, and what about FF?

Martin Honnen

не прочитано,
7 янв. 2007 г., 08:07:5707.01.2007
homers...@gmail.com wrote:
> I have selection range object. Now I need to replace it contents with
> my HTML code. How can I do that?

Delete the existing contents and create the new contents with the DOM e.g.

var selection = window.getSelection();
var range = selection.getRangeAt(0);
if (range) {
range.deleteContents();
var newContents = document.createElement('span');
newContents.textContent = 'Kibology for all.';
range.insertNode(newContents)
}


--

Martin Honnen
http://JavaScript.FAQTs.com/

Alex Vincent

не прочитано,
11 янв. 2007 г., 11:51:0211.01.2007

Martin, I've actually been thinking about this quite a bit lately -- in
the context of transactions (do, undo, redo). It's not clear at all how
to do that correctly. Can you give me some advice?

Alex

0 новых сообщений