【问题标题】:Disable all Joomla 3.0 inline styling禁用所有 Joomla 3.0 内联样式
【发布时间】:2013-08-31 13:28:22
【问题描述】:

我需要禁用所有的 joomla 内联样式。

我的查询与文本编辑器无关。 在大多数情况下,我对内联样式完全没有用处。

这真的让我很吃力,尤其是在当前使用自定义模板的项目中。

有什么解决办法吗?或插件? (我已经搜索过了)

【问题讨论】:

  • 可能在主模板中添加一些 jquery 代码?
  • 我知道我可以做到这一点,也可以通过 css 覆盖 [style]。但我更喜欢更清洁的解决方案。
  • 你在哪里看到内联样式,我以为Joomla 3.1核心没有任何内联样式。
  • 我构建了没有样式的模板。布局流畅,一切都适合屏幕和调整大小。然后我用内容(文本和图像)填充网站。文章内容之外的标题和其他部分似乎具有内联样式。这是文本编辑器的噩梦。所以我需要一个后端/cms解决方案,JS不会削减它。

标签: css joomla joomla-extensions joomla3.0


【解决方案1】:

请注意,这将删除所有元素的内联“样式”属性:

<script type="text/javascript">
(function($){
    $(document).ready(function(){
       $(this).find("*").removeAttr("style");
    });
})(jQuery);
</script>

为了绝对有效,请将其放在 &lt;/body&gt; 标记之前,以防万一您有任何其他 jQuery 脚本将 css("something") 添加到元素。

【讨论】:

    【解决方案2】:

    这是一个简单的插件,您可以运行并使用它来查找哪些元素包含哪些属性,例如类、样式、标题、宽度等。 拨弄http://jsfiddle.net/SyFum/2/

    <script type="text/javascript">
        (function ($) {
            $( document ).ready( function () {
    
                /**
                 * Highlight all elements that contain an attribute
                 * @param attributeToSearch string The attribute to be found
                 * @returns {*} The elements, containing the attribute, bordered
                 */
                $.fn.StyleHighlighter = function (attributeToSearch) {
                    // set the defaults
                    var defaults = {
                        attributeToSearch : "style"
                    };
    
                    $( this ).find( "*" ).each( function () {
    
                        if ($( this ).attr( attributeToSearch ))
                        {
                            $( this ).css( "border", "1px dashed #ff0000" );
                        }
                    } );
                    return this;
                };
    
                // Usage (style, class, title, whatever)
                $( this ).StyleHighlighter( "style" );
            } );
        })( jQuery );
        </script>
    

    【讨论】:

      猜你喜欢
      • 2013-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-09
      • 2011-09-27
      • 1970-01-01
      • 1970-01-01
      • 2023-01-30
      相关资源
      最近更新 更多