【发布时间】:2015-08-16 09:40:02
【问题描述】:
要在 FireFox 中显示网站源,您只需在 URL 前输入 view-source:<URI-here>。
示例:view-source:https://www.facebook.com/
【问题讨论】:
要在 FireFox 中显示网站源,您只需在 URL 前输入 view-source:<URI-here>。
示例:view-source:https://www.facebook.com/
【问题讨论】:
转到首选项 -> 高级并启用开发人员菜单。然后从开发者菜单中你可以查看源代码。
【讨论】:
直接,不。 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, "<").replace(/>/g, ">");
// 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>
【讨论】: