【问题标题】:Code works on stack snippet different to a single html file代码适用于与单个 html 文件不同的堆栈片段
【发布时间】:2015-07-19 13:12:06
【问题描述】:

我有一些代码,它在堆栈 sn-p 上运行良好。

但是当我将它插入到我的服务器或 .html 文件中时,刷新按钮会变小!

<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.css" rel="stylesheet"/>
<link href="http://cdnjs.cloudflare.com/ajax/libs/jquery-bootgrid/1.1.4/jquery.bootgrid.css" rel="stylesheet"/>

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-bootgrid/1.1.4/jquery.bootgrid.js"></script>


<script>
 $(function () {
      var testGrid = $("#testGrid").bootgrid({
        navigation: 3,
        ajax: true,
        url: "controllers/getListFiles",
        post: function () {
          return {
            type: 'req',
            expanded: $('#exp').text()
          };
        },
        responseHandler: function (response)
        {
          return response.data;
        }
      });
    });
</script>



    <div id="autoOut" class="tab-pane fade in active">
      <span id="exp" style="display: none;"></span>
      <h3>Auto OUT</h3>
      <table id="testGrid" class="table table-condensed table-hover table-striped">
        <thead>
          <tr>
            <th data-column-id="date" class="col-md-3">Дата/Время</th>
            <th data-column-id="expander" data-formatter="expander" class="col-md-1">Список</th>
            <th data-column-id="file" class="col-md-4">Имя файла</th>
            <th data-column-id="uid" class="col-md-4">UID</th>
            <th data-column-id="accReqId" class="col-md-2">AccountsRequestId</th>
          </tr>
        </thead>
      </table>
    </div>
有代码的复制和粘贴,没有什么不同!是否有一些 sn-p 羽毛使它工作,我怎样才能让它在我的服务器上工作? 有关我以前的question 的更多信息。

【问题讨论】:

  • 您使用的是什么文档类型?
  • @HiddenHobbes 嗯...如您所见,什么都没有。让我尝试添加一些东西。
  • 尝试包含 reset.css 或 normalize.css,就像在这个问题中一样:stackoverflow.com/questions/12582624/…
  • @HiddenHobbes 真是愚蠢的错误!所有适用于文档类型!谢谢!把它作为答案,这样其他人就会看到解决方案。
  • @TEXHIK 没问题,其中一个你只需要另一双眼睛的情况! :) 当我偶然发现解决方案时,我用完整的答案充实了我的回答。

标签: javascript jquery html jquery-bootgrid


【解决方案1】:

确保在将代码移动到其自己的 html 文件时指定 doctype。 Stack Snippets 和 JS Fiddle 会自动将 HTML5 文档类型 &lt;!DOCTYPE html&gt; 添加到它们的输出中(尽管在 JS Fiddle 的情况下这是可配置的)。不提供 doctype 会导致奇怪的结果,因为浏览器不知道要使用哪种渲染模式。

取自http://www.w3.org/QA/Tips/Doctype

但最重要的是,对于大多数浏览器系列来说,一个 doctype 声明将使很多猜测变得不必要,从而触发“标准”渲染模式。

【讨论】:

    猜你喜欢
    • 2017-03-14
    • 2021-12-09
    • 1970-01-01
    • 1970-01-01
    • 2015-07-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多