【问题标题】:Is there a way for "view:source" on Safari? [closed]有没有办法在 Safari 上“查看:源”? [关闭]
【发布时间】:2015-08-16 09:40:02
【问题描述】:

要在 FireFox 中显示网站源,您只需在 URL 前输入 view-source:<URI-here>。

示例:view-source:https://www.facebook.com/

【问题讨论】:

    标签: html firefox view safari


    【解决方案1】:

    转到首选项 -> 高级并启用开发人员菜单。然后从开发者菜单中你可以查看源代码。

    【讨论】:

    • 你误解了我的问题。我想通过链接调用源代码;)查看源代码:xxxxxxx.com
    【解决方案2】:

    直接,不。 Safari 不支持以“view-source:”开头的地址。

    另一个 SO 问题 here 有一个解决方案。标签的内容被javascript抓取并放在一个弹出窗口中。但它只适用于显示当前网站的内容。

    test.html:

    <html>
    <head>
    <script type="text/javascript">
    function ViewSource()
    {
        var source = "<html>" + document.getElementsByTagName('html')[0].innerHTML + "</html>";
        // replace < and > symbols
        source = source.replace(/</g, "&lt;").replace(/>/g, "&gt;");
        // add <pre> tags
        source = "<pre>"+source+"</pre>";
        // open the window
        sourceWindow = window.open('','View source!','height=800,width=800,scrollbars=1,resizable=1');
        // set the source as the content
        sourceWindow.document.write(source);
        // close the document for writing, not the window
        sourceWindow.document.close(); 
        // give source window focus
        if(window.focus) sourceWindow.focus();
    }
    </script>
    </head>
    <body>
        <input type="button" value="View source!" onClick="ViewSource()" />
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-15
      • 2010-10-29
      • 1970-01-01
      • 2020-06-17
      • 2021-07-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多