百度UEditor编译器中添加HTML最快捷的办法

之前写了一篇关于百度百度UEditor编译器中添加HTML的博客:

http://blog.youkuaiyun.com/yingjia11/article/details/78443319

我的html代码是这样的:

<script id="editor" type="text/plain" style="width: 100%; height: 50%;"></script>
<code id="content" style="display:none;">
    ${content}
</code>
js代码是这样的

var editor = new UE.ui.Editor();
	editor.render('editor');
	editor.addListener( 'ready', function(edt) {  
        var content_old = $('#content').html();  
        if(content_old!=''){
            editor.execCommand('insertHtml', content_old);  
        }  
    });
但后来看评论说,可以直接把代码放script标签中,我就尝试地去掉code标签:

<script id="editor" type="text/plain" style="width: 100%; height: 50%;">
	${content}
</script>
<!-- <code id="content" style="display:none;">
${content}
</code> -->
然后js里面去掉

//	editor.addListener( 'ready', function(edt) {  
//        var content_old = $('#content').html();  
//        if(content_old!=''){
//            editor.execCommand('insertHtml', content_old);  
//        }  
//    }); 
这部分,发现果然也可以,但是反复操作后发现,怎么前后空格行越来越多了




折腾了半天,原来是因为默认把script中的全部内容放上去了,所以html里面这样写就好了

<script id="editor" type="text/plain" style="width: 100%; height: 50%;">${content}</script>
中间不能加任何空格或者换行!

搞定!



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值