页面源怎么可能不显示页面上的内容? [英] How is it possible for the page source not to show what is on the page?

查看:29
本文介绍了页面源怎么可能不显示页面上的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的网页:

我试图找出为什么我的列表没有正确显示,但这是另一篇文章.为了排除故障,我右键单击页面并选择查看页面源.正如您在下面看到的,该人员列表(Adam Kinkaid 等)甚至没有出现.这怎么可能?

页面来源:

<头><title>Presto</title><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black"/><meta name="format-detection" content="telephone=no"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="/Content/ie10mobile.css" rel="stylesheet"/><link href="/Content/jquery.mobile-1.3.2.css" rel="stylesheet"/><link href="/Content/jquery.mobile.structure-1.3.2.css" rel="stylesheet"/><link href="/Content/jquery.mobile.theme-1.3.2.css" rel="stylesheet"/><link href="/Content/bootstrap.css" rel="stylesheet"/><link href="/Content/bootstrap-responsive.css" rel="stylesheet"/><link href="/Content/durandal.css" rel="stylesheet"/><link href="/Content/toastr.css" rel="stylesheet"/><link href="/Content/app.css" rel="stylesheet"/><script type="text/javascript">如果 (navigator.userAgent.match(/IEMobile/10.0/)) {var msViewportStyle = document.createElement("style");var mq = "@-ms-viewport{width:auto!important}";msViewportStyle.appendChild(document.createTextNode(mq));document.getElementsByTagName("head")[0].appendChild(msViewportStyle);}<身体><div id="applicationHost"><div class="page-splash"></div><div class="page-splash-message">普雷斯托

<div class="progress progress-striped active page-progress-bar"><div class="bar" style="width: 100%;"></div>

<script src="/scripts/jquery-1.9.1.js"></script><script src="/scripts/jquery.mobile-1.3.2.js"></script><script src="/scripts/knockout-2.2.1.debug.js"></script><script src="/scripts/sammy-0.7.4.js"></script><script src="/scripts/toastr.js"></script><script src="/scripts/Q.js"></script><script src="/scripts/breeze.debug.js"></script><script src="/scripts/bootstrap.js"></script><script src="/scripts/moment.js"></script><script type="text/javascript" src="/App/durandal/amd/require.js" data-main="/App/main"></script>

解决方案

查看源代码"只会在页面加载时为您提供原始页面源代码.之后内容可能是用 JavaScript 添加到页面的.

看起来页面正在使用 require.js 动态加载模块:

<script type="text/javascript" src="/App/durandal/amd/require.js" data-main="/App/main></script>

您可以查看加载的 main.js 脚本,看看它是否正在添加元素.

使用浏览器的开发者工具探索 DOM 以获取当前的源".

使用 Chrome,只需点击 Ctrl+Shift+i 即可打开开发者工具,或右键单击某个元素并检查"它.

This is my web page:

I'm trying to find out why my list isn't showing up correctly, but that's another post. To troubleshoot, I right-clicked on the page and chose View page source. As you can see below, that list of people (Adam Kinkaid, etc.) doesn't even show up. How is that possible?

Page source:

<!DOCTYPE html>
<html>
<head>
    <title>Presto</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <link href="/Content/ie10mobile.css" rel="stylesheet"/>
<link href="/Content/jquery.mobile-1.3.2.css" rel="stylesheet"/>
<link href="/Content/jquery.mobile.structure-1.3.2.css" rel="stylesheet"/>
<link href="/Content/jquery.mobile.theme-1.3.2.css" rel="stylesheet"/>
<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/bootstrap-responsive.css" rel="stylesheet"/>
<link href="/Content/durandal.css" rel="stylesheet"/>
<link href="/Content/toastr.css" rel="stylesheet"/>
<link href="/Content/app.css" rel="stylesheet"/>

    <script type="text/javascript">
        if (navigator.userAgent.match(/IEMobile/10.0/)) {
            var msViewportStyle = document.createElement("style");
            var mq = "@-ms-viewport{width:auto!important}";
            msViewportStyle.appendChild(document.createTextNode(mq));
            document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
        }
    </script>
</head>
<body>
    <div id="applicationHost">
        <div class="page-splash"></div>
<div class="page-splash-message">
    Presto
</div>
<div class="progress progress-striped active page-progress-bar">
    <div class="bar" style="width: 100%;"></div>
</div>

    </div>

    <script src="/scripts/jquery-1.9.1.js"></script>
<script src="/scripts/jquery.mobile-1.3.2.js"></script>
<script src="/scripts/knockout-2.2.1.debug.js"></script>
<script src="/scripts/sammy-0.7.4.js"></script>
<script src="/scripts/toastr.js"></script>
<script src="/scripts/Q.js"></script>
<script src="/scripts/breeze.debug.js"></script>
<script src="/scripts/bootstrap.js"></script>
<script src="/scripts/moment.js"></script>

            <script type="text/javascript" src="/App/durandal/amd/require.js" data-main="/App/main"></script>
</body>
</html>

解决方案

"View Source" is only going to give you the original page source from when the page loaded. Content was probably added to the page with JavaScript after that.

It looks like the page is loading modules dynamically with require.js:

<script type="text/javascript" src="/App/durandal/amd/require.js" data-main="/App/main></script>

You can look at the main.js script that gets loaded to see if it's what's adding elements.

Use your browser's Developer Tools to explore the DOM to get the current "source".

With Chrome, just hit Ctrl+Shift+i to open up the Developer Tools, or right-click on an element and "Inspect" it.

这篇关于页面源怎么可能不显示页面上的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
C#/.NET最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆