>Форум Mozilla Россия http://forum.mozilla-russia.org/index.php >Разработка http://forum.mozilla-russia.org/viewforum.php?id=18 >Воткнуть HTML http://forum.mozilla-russia.org/viewtopic.php?id=35674 |
Keepun > 06-06-2009 20:35:23 |
Сейчас мода на текстовые области, которые кажут полноценную картинку в фрейме. Например, GMail, Mail.ru, Одноклассники и т.д. Как в них вставить HTML на месте курсора? Всталяет, как обычные текст: Выделить код Код:var command = "cmd_insertText"; var controller = document.commandDispatcher.getControllerForCommand(command); if (controller && controller.isCommandEnabled(command)) { controller = controller.QueryInterface(Components.interfaces.nsICommandController); var params = Components.classes["@mozilla.org/embedcomp/command-params;1"]; params = params.createInstance(Components.interfaces.nsICommandParams); params.setStringValue("state_data", aText); controller.doCommandWithParams(command, params); } |
Anton > 06-06-2009 22:35:51 |
В xul-ный textarea картинку вставить можно, в html-ный у меня не получается. |
Keepun > 08-06-2009 00:01:00 |
Anton, тогда как выполнить команду для этого Мидаса? http://www.mozilla.org/editor/midasdemo/ - для теста Выделить код Код:var focused = document.commandDispatcher.focusedElement; // Вернет NULL, когда курсор находит в "Мидасе" focused.execCommand('insertimage', false, URL); |
Anton > 08-06-2009 16:28:58 |
Выделить код Код:var focused = getBrowser (). contentDocument. activeElement; focused. contentWindow. document. execCommand('insertimage', false, URL); |
Keepun > 08-06-2009 19:18:25 |
Anton, спасибо за наводку Выделить код Код:var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem) .rootTreeItem .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindow); mainWindow.getBrowser() ... |