简体   繁体   English

Firefox 加<br>剑道编辑器用户输入末尾的标签

[英]Firefox adding <br/> tag at the end of kendo editor user input

I have a simple kendo editor in my MVC app.我的 MVC 应用程序中有一个简单的剑道编辑器。 When using Firefox, BR tag is being added at the end of the string typed into the editor.使用 Firefox 时,将在输入编辑器的字符串末尾添加 BR 标签。 This does happen in Firefox only.这只发生在 Firefox 中。

@(Html.Kendo().Editor()
.Name("MyEditor")
.HtmlAttributes(new { cols = "5", rows = "5", style = "width: 500px;height:50px" })
.Tools(tools => tools.Clear())
)

var r = $('#MyEditor').data('kendoEditor').value()

How should it be fixed, so I don't get the unwanted html?应该如何修复它,这样我就不会得到不需要的 html?

I checked the demos at the Telerik site.我在 Telerik 站点查看了演示。 With Firefox and Safari.与 Firefox 和 Safari。 None of them are returning a br tag.他们都没有返回 br 标签。 Guess you are not using the latest version and this version has a bug.猜你没有使用最新版本,这个版本有一个错误。

As workaround you can check the value and remove the tag.作为解决方法,您可以检查值并删除标签。

var text = 'LoremIpsum<br/>';
if (text.endsWith('<br/>')) text = text.slice(0, -5);
alert(text);

I've got it resolved by using the following code found on this site.我已经通过使用本网站上的以下代码解决了这个问题。

function stripHTML(html) {
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || "";
}

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

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