简体   繁体   English

jQuery方法前置在Internet Explorer中不起作用

[英]JQuery method prepend does not work in Internet Explorer

I´ve worked on the text editor and there are one plugin that was created to putting header and footer (basically a row of table) in the editor and one of the business rules is don´t to permit move the header or footer (My version is 3.3.8 but I tested in the last 3.4.6). 我从事过文本编辑器的工作,并且创建了一个插件来在编辑器中放置页眉和页脚(基本上是一行表),并且其中一项业务规则是不允许移动页眉或页脚(我的版本是3.3.8,但我在最近的3.4.6中进行了测试)。

I created a method in the basic_config.js, basically inside of the method "ed.onChange.add(function(ed, l)" to readjust the position of header or footer when the user try to move the table to another place, like this: 我在basic_config.js中创建了一个方法,基本上是在方法“ ed.onChange.add(function(ed,l)”内部)中,以在用户尝试将表移至另一个位置时重新调整页眉或页脚的位置,例如这个:

           //find out the div of the header
            var elm = tinyMCE.activeEditor.dom.get("testeHeader");

           //case the elm move of position...
           if(elm != null) {
                var txt = tinyMCE.activeEditor.dom.getOuterHTML(elm);
                $(elm).remove(); 
                //relocates the header to the top does not works on IE8.
                $('#editor1_ifr').contents().find('body').prepend(txt);**
            }

In the Firefox it works but in the Internet Explorer de method prepend fail, nothing happers. 在Firefox中,它可以工作,但是在Internet Explorer de方法中,前置失败,没有任何麻烦。

There any solution for this cause? 有什么解决办法吗?

Thank a bunch for all that get help! 感谢您提供的所有帮助!

This might work. 这可能有效。 Give it a try 试试看

var txt = tinyMCE.activeEditor.dom.getOuterHTML(elm);
$(elm).remove(); 
//relocates the header to the top does not works on IE8.
var ed = tinyMCE.activeEditor;
var parent = ed.getBody();
parent.insertBefore( $(txt).get(0), parent.childNodes[0] );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM