<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>12-3 源代码的简单隐藏</title>
<script>
window.onload = function(){
var str;
str = document.documentElement.outerHTML;
document.open();
document.write("<!-- 你能看到真正的源代码吗? -->");
document.close();
document.body.innerHTML = str;
}
</script>
</head>
<body style="overflow:auto; padding:0px; margin:0px;">
<div style="font-size:14px; font-weight:bold; color:white; font-family:Arial, 宋体; background-color:#6090DA; padding:4px 10px;">
你好
<script>
dt = new Date();
document.write(",当前时间是 ");
document.write(dt.toLocaleTimeString());
</script>
</div>
</body>
</html>---------------------------------------------------------------------------------------------
document.open()方法不是是新建一个新的文档,把原来的文档清空么?这个事例(IE上运行)怎么在window.onload执行到document.open()的时候不是把页面的内容擦除了么?按理是什么东西都是不存在的了.怎么全部都还在...刷新之后什么都没了.不解~~~javascript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
window.onload = function(){
//var str;
//str = document.documentElement.outerHTML;
document.open();
document.write("<!-- 你能看到真正的源代码吗? -->");
document.close();
//document.body.innerHTML = str;
}
</script>
</head>
<body style="overflow:auto; padding:0px; margin:0px;">
<div style="font-size:14px; font-weight:bold; color:white; font-family:Arial, 宋体; background-color:#6090DA; padding:4px 10px;">
你好
<script>
dt = new Date();
document.write(",当前时间是 ");
document.write(dt.toLocaleTimeString());
</script>
</div>
</body>
</html>
re:
你是先先取的 str 值,再open 的,close后又把 str写回去了还有就IE下刷新这个页面,然后就什么都不见了....why?大神解救....
re:
ie几呀
-------------
ie7~9都是这样~
-------------
不纠结这个问题了~~
-------------
ie7~9都是这样~
-------------
不纠结这个问题了~~
那么说str的值是存在内存的?
re:
对