TinyMCE - 插入隐藏的 INPUT 标签
这里确实需要一些帮助...我有以下代码:
<a href="javascript:;" onmousedown="addMailMergeItem()">[Insert Item]</a>
<script type="text/javascript">
function addMailMergeItem(){
tinymce.execCommand('mceInsertContent',false,'<input type=\'hidden\' name=\'a\' value=\'1\'/>');
}
</script>
但是,单击 [插入项目] 时添加的 HTML 是:
<P><INPUT value=1 type=hidden name=a></P>
这使得输入字段可见,因为“隐藏”类型无法识别!
我怎样才能修改 execCommand() 行来实现我想要的..?
塔米姆。
Really need some help here...I have the following code:
<a href="javascript:;" onmousedown="addMailMergeItem()">[Insert Item]</a>
<script type="text/javascript">
function addMailMergeItem(){
tinymce.execCommand('mceInsertContent',false,'<input type=\'hidden\' name=\'a\' value=\'1\'/>');
}
</script>
However on clicking [Insert Item] the HTML added is:
<P><INPUT value=1 type=hidden name=a></P>
which makes the input field visible as the 'hidden' type is not recognised!
How can I amend the execCommand() line to achieve what I am after..?
Tamim.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试
try
除了 Andrei G 的答案之外,您还应该检查 valid_elements 是否包含输入元素的给定属性。否则该属性将被tinymce 清理函数删除。
Additional to Andrei Gs answer you should check if valid_elements contains the given attributes for input elements. Otherwise the attribute gets stripped by the tinymce cleanup function.
看起来这是一个浏览器问题。可以确认问题在ie8中明显:
http://www.tinymce.com /forum/viewtopic.php?id=24899
http://www.tinymce.com/forum/viewtopic.php?id=6994
http://www.tinymce.com/forum/viewtopic.php?id=8499
Very much looks like this is a browser issue. Can confirm that the problem is manifest in ie8:
http://www.tinymce.com/forum/viewtopic.php?id=24899
http://www.tinymce.com/forum/viewtopic.php?id=6994
http://www.tinymce.com/forum/viewtopic.php?id=8499
我没有深入研究这个问题,我找到了答案并为我工作了一个魅力:
I didn't dig much into this, i found the answer and worked for me as a charm: