【问题标题】:TYPO3 CKeditor not rendering javascript linkTYPO3 CKeditor 不呈现 javascript 链接
【发布时间】:2018-04-18 10:36:57
【问题描述】:

我使用的是 TYPO3 8.7.8,并且必须提供一个 javascript 链接才能停用 Google Analytics。

链接应如下所示:

<a href="javascript:gaOptout()" onclick="alert('Google Analytics is now deactivated');">Deactivate Google Analytics</a>

不幸的是,链接没有出现在前端,这意味着它只是&lt;p&gt; 标记内的普通文本。但是在后端一切都很好,它在那里显示为一个链接......

这是我的 CKeditor 的 yaml 配置:

# Load default processing options
imports:
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml" }

# Configuration for the editor
# For complete documentation see http://docs.ckeditor.com/#!/api/CKEDITOR.config
editor:
  config:
    allowedContent: true
    linkJavaScriptLinksAllowed: true
    contentsCss: ["EXT:rte_ckeditor/Resources/Public/Css/contents.css", "EXT:my_extension/Resources/Public/Stylesheets/styles.css", "EXT:my_extension/Resources/Public/Stylesheets/fonts.css"]
    resize_enabled: true

    stylesSet:
    # block level styles
    - { name: "Button Default", element: "a", attributes: { 'class': 'btn btn-default', 'role': 'button', 'aria-pressed': 'true'}}

    format_tags: "p;h1;h2;h3;h4;h5;pre"

    toolbarGroups:
      - { name: styles, groups: [ styles, format ] }
      - { name: basicstyles, groups: [ basicstyles ] }
      - { name: paragraph, groups: [ list, indent, blocks, align ] }
      - { name: links, groups: [ links ] }
      - { name: clipboard, groups: [ clipboard, cleanup, undo ] }
      - { name: editing, groups: [ spellchecker ] }
      - { name: insert, groups: [ insert ] }
      - { name: tools, groups: [ table, specialchar ] }
      - { name: document, groups: [ mode ] }

    justifyClasses:
      - text-left
      - text-center
      - text-right
      - text-justify

    extraPlugins:
      - justify

    removePlugins:
      - image

    removeButtons:
      - Anchor
      - Underline
      - Strike

buttons.:
  link.:
    queryParametersSelector.:
      enabled: true

我在这里错过了什么?

【问题讨论】:

    标签: ckeditor typo3


    【解决方案1】:

    我们遇到了同样的问题——我们为typo3写了一个小链接处理程序,只允许javascript:gaOptOut();链接。

    在这里获取: https://www.infoworxx.de/download/ifx_linkhandler_googleAnalytics.zip

    塞巴斯蒂安

    【讨论】:

    • 立即工作。谢谢!
    • 该链接现在在 RT-Editor 中被接受,但它没有放在前端。编辑:我不小心写了 Javascript:... 而不是 javascript。
    【解决方案2】:

    这不是 ckeditor 的问题,而是 TYPO3 本身为避免安全问题而禁止的 - XSS。

    我使用的解决方案类似于TYPO3 force internal links to cross domain pages to use https in news,因此编辑器例如链接到http://ga-output.tld,这将被JS链接替换。

    【讨论】:

      【解决方案3】:

      您可以使用源按钮 () 在 ckeditor 中为您的链接添加一个类。

      <a class="gaOptout" href="#">your linked text</a>
      

      现在您只需将函数重写为这样的 onclick 事件:

      $('.gaOptout').on('click', function(){
      your function
      });
      

      【讨论】:

        【解决方案4】:

        这似乎仍然是 T3 9.5 中的一个问题,尤其是使用此 Google OptOut 脚本。 无需编码的简单解决方法:我们剪下包含 javascript 的段落并将其放在单独的 html 元素中。只需从 CKEs Source-view 中将其剪下,然后将其粘贴到新元素中。要使文章保持顺序,只需剪下其余文本并将其粘贴到新的文本元素中即可。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-07-09
          • 1970-01-01
          • 2020-04-21
          • 1970-01-01
          • 2011-02-27
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多