我使用goog.dom.safeHtmlToNode谷歌关闭图书馆sanitizer.sanitize消除了对DOM元素我的ID
动态地更新与内容标签,因为谷歌的封库的更新版本中删除的DOM片段方法:goog.dom.htmlToDocumentFragment(htmlString)。
消毒剂去除从DOM元素我的 “ID = XYZ”。例如:
'<input type="email" id="openid" name="openid" size="20" style="font-size: 18px" />'
成为
'<input type="email" size="20" style="font-size: 18px;" />'
我所用的ID来获得内容从这些元素的用户输入。 我如何告诉卫生洗涤剂不要删除这些属性?我曾尝试下面的代码没有成功:
var sanitizer =
new goog.html.sanitizer.HtmlSanitizer.Builder()
.withCustomNetworkRequestUrlPolicy(goog.html.SafeUrl.sanitize)
.allowCssStyles()
.allowFormTag()
.addOriginalTagNames()
.allowDataAttributes([ "data-id","data-name" ]) //data-* attributes are inert as per HTML5 specs
.build();
goog.dom.safeHtmlToNode(sanitizer.sanitize (htmlString));
我也曾尝试重新命名我的“ID”到“数据ID”,该字符串仍从消毒输出中删除。
Thank you in advance for your help on this matter.
谢谢。制定政策的伎俩。我在哪里可以找到关于谷歌封闭库的其他文档,即教程,例子(是的,我知道它附带的演示)。我通常使用测试程序来弄清楚如何调用函数。这将是很好,有更多的信息!无论如何谢谢!它现在工作! – Lillian
主要网站是https://developers.google.com/closure/library/ – ghosttie