首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有一种在Safari上“查看:源代码”的方法?

有没有一种在Safari上“查看:源代码”的方法?
EN

Stack Overflow用户
提问于 2013-12-26 01:54:00
回答 2查看 2K关注 0票数 0

要在FireFox中显示站点源,只需在view-source:<URI-here>之前键入view-source:<URI-here>即可。

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-12-30 19:08:41

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

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

test.html:

代码语言:javascript
复制
<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>
票数 0
EN

Stack Overflow用户

发布于 2013-12-26 01:56:37

转到preferences -> advanced启用developer菜单。然后,从developer菜单中可以查看源代码。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20778301

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档