【问题标题】:problem in <html dir="rtl"> pages and google plus one button<html dir="rtl"> 页面和谷歌加一个按钮中的问题
【发布时间】:2011-08-25 11:55:59
【问题描述】:

我有一个 rtl 格式的 HTML 页面,其中包含以下代码,而 Google 加一按钮在页面中显示效果不佳。 在加载 plusone.js 文件之前,由于 html 标记中的 dir="rtl" 存在一个非常大的水平滚动。 加载 plusone.js 后,滚动将消失。 我怎样才能避免出现和消失这个水平滚动。(我不想从标签中删除 dir="rtl")

<html xmlns="http://www.w3.org/1999/xhtml" dir="rtl">
<head>
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>
</head>
<body>
<div id="content">
   <div class="g-plusone" data-size="small" data-annotation="none"></div>
</div>
</body>
</html> 

【问题讨论】:

    标签: html google-plus-one right-to-left


    【解决方案1】:

    我刚刚为我的网站修复了这个问题

    我的问题是我网站中的每个文章页面都有一个水平滚动条。 经过长时间的调查,我发现 Google 加一按钮存在错误 仅当页面使用 Direction=rtl 样式时,此错误才可见。

    如何解决 只要错误是相关的(希望谷歌会尽快修复它),只需将其添加到您的 css 文件中

    iframe[id^="oauth2relay"]
    {
        right:100px;
    }
    

    这将为任何名为“oauth2relay”(google plus 一个脚本)的 iframe 恢复页面的正确位置

    我在我的网站的每个文章页面中都使用它 - 您可以查看它 - 只需使用 firebug 在任何文章中搜索“oauth2relay”

    我的网站是www.mentallica.co.il 文章举例:example

    【讨论】:

      【解决方案2】:

      脚本不允许您更改元素 但是有一个简单的解决方案 相反,将 dir = "rtl" 设置为 html 或 body 以为主 div 执行此设置

      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <script type="text/javascript">
          (function () {
              var po = document.createElement('script'); po.type = 'text/javascript';    po.async = true;
                  po.src = 'https://apis.google.com/js/plusone.js';
                  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
          })();
      </script>
      </head>
      <body>
      <div id="content" style="direction: rtl;">
         <div class="g-plusone" data-size="small" data-annotation="none"></div>
      </div>
      </body>
      </html> 
      

      【讨论】:

        【解决方案3】:

        将此 css 添加到您的 css 文件中,此代码对我有用

        iframe[id^="oauth2relay"] { position: fixed !important; }
        

        【讨论】:

          【解决方案4】:

          此错误现已在 Google+ Javascript 中得到修复。您应该不再需要进行任何更改以使事情正常工作。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2017-10-28
            • 2023-03-07
            • 2013-04-30
            • 2019-03-07
            • 1970-01-01
            相关资源
            最近更新 更多