【问题标题】:node get the source code from url and displaynode从url获取源代码并显示
【发布时间】:2016-02-14 18:38:35
【问题描述】:

我正在使用 node-webkit 创建一个应用程序。我需要从 url 中获取网页并显示它。

我尝试过使用request 模块。它正确获取源代码内容。但在显示时,css文件和图像不显示。

我不能使用 iframe,因为像 http://www.flipkart.com 这样的网站无法加载到 iframe 中,它会替换整个页面。

我不能在这里使用 php..

jquery 中有没有合适的 dom 解析器??

(有什么方法可以正确显示css和图像,以便我可以继续使用请求模块)

【问题讨论】:

    标签: jquery node.js node-webkit node-modules domparser


    【解决方案1】:

    如果你想加载外部网站来检查它们是否是主窗口,nw.js 有一个属性你可以放在 iframe 上,让内容误以为它是顶部/主框架:nwfaketop。这将删除对window.parentwindow.top 的访问。

    此外,如果您正在加载外部内容,您可能希望将其与 nwdisable 结合使用,这会禁用 iframe 中的 Node。

    例子:

    <!DOCTYPE html>
    <html>
        <head>
            <title>iframe test</title>
        </head>
        <body>
            <iframe width="600" height="600" src="http://www.flipkart.com" nwdisable nwfaketop></iframe>
        </body>
    </html>
    

    更多信息可以在 nw.js 文档中找到:https://github.com/nwjs/nw.js/wiki/Mini-browser-in-iframe

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-12
      • 2011-07-14
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多