innerHTML W3C 等效项

发布于 2024-08-03 20:53:06 字数 590 浏览 3 评论 0原文

我正在使用几年前用 asp/vbscript(旧的 asp)制作的 cms,直到我们发布 dot net cms(应该很快),我们一直在使用这个,但目前我正试图让它变得更加 w3c兼容...目前我们的cms仅适用于IE...在页面编辑器中,

您可以在预览状态和html模式之间来回切换,编辑器使用innerHTML来交换模式,但是innerhtml使所有标签都处于大写状态并使所有< code>

  • ...
  • 标签,例如
  • ...
  • 没有结束标签,因为它是可选的...我可以抓取所有 html使用正则表达式将标签和属性键交换为小写,但我想知道是否有人知道更简单的方法...我尝试添加严格模式文档类型,不幸的是,因为编辑器的代码确实很旧,整个编辑器都崩溃了...

    希望我们很快就会发布新的 cms,但是我们将所有网站转移到新的 cms 之前还需要一段时间,所以在那之前我会尝试改进我们的旧代码,

    是否有任何与innerHtml 等效的东西可以使代码更简洁w3c 兼容 AKA 将结束标记保留在我的

  • 中,这样我就不会开始使用正则表达式解析我的 ccode 并替换 ? 蒂

    im working with a cms made a few years ago in asp/vbscript (old asp) and until we release out dot net cms (should be soon) we are stuck with this one but at the moment im trying to make it a bit more w3c compliant ... currently our cms is IE only ... in the page editor

    you can switch back and forth from Preview state and html mode and the editor use innerHTML to swap mode but that innerhtml makes all the tags in cap and makes all <LI>...</LI> tags like that <LI>...

    no closing tags since it was optional ... i can grab all html tags and attribute keys using regex and swap them to lower case but i was wondering if anyone know an easier way to do so... i tried adding strict mode doctype unfortunately since the code of the editor is really old the whole editor jsut fall apart ...

    hopefully we are gonna release our new cms soon but its gonna be a while until we transfer all our sites to the new cms so until then im trying to improve our old code

    is there any equivalent to innerHtml that would make the code more w3c Compliant AKA keep the closing tag to my <li></li> so i dont start parsing my ccode using regex and replace
    ?
    ty

    如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(1

    青萝楚歌 2024-08-10 20:53:06

    如果我理解正确,答案是“不要这样做”,除非您要在“预览”模式下对代码进行任何更改。

    如果该预览只是普通预览(不是所见即所得),您应该这样做:

    切换到“预览”模式时,隐藏编辑器(….style.display='hidden' 或类似的内容那)保留内部代码不变,并将其复制到预览元素的innerHTML。

    当切换回来时,您只需丢弃innerHTML 中的代码并再次显示旧内容的编辑器。

    If I understand you right, the answer is ‘don't do it’ unless you're going to make any changes to the code in the ‘Preview’ mode.

    If that Preview is just plain preview (no WYSIWYG), you should do it like that:

    When switching to ‘Preview’ mode, hide the editor (….style.display='hidden' or something like that) leaving the code unmodified inside, and copy it to innerHTML of the preview element.

    When switching back, you just discard the code from innerHTML and display editor with old contents again.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文