请问如何用javascript写一个方法,从打开这个URL到完成(如状态栏下的‘完毕’)所用的时间。
解决方案 »
- 一个小问题,JavaScript的onclick事件在火狐下的不执行
- 这个查询功能怎么实现.特急
- 正则表达式的问题,梅花雪请进。
- 怎么控制JS的执行时间?
- 如何在网页中嵌入一个功能可以定制的文本编辑器?
- 怎样通过js更换iframe框架指向的页面
- 请把这段JAVA代码改为JavaScript,该功能实现小写金额转换为大写,急急急!!!!
- 怎样判断一个input的type为checkbox的选中属性??用 jQuery
- 谁有可兼容ie11的easyAccordion
- Js报路径错误解决
- 怎样把照片和文字加载到新的网页上?特急请赐教!
- 对于一个函数,当执行到函数中间时,有没有什么办法可以暂停等待指定的时间,再执行剩下的代码
var seconds=0;
function calculate(){
if(document.readyState!='complete'){seconds++;setTimeout('calculate',1000);}
}
</script>
<body onLoad="calculate()">
<script language="javascript">
document.write("加载时间为"+seconds+"秒");
</script>
</body>
这样行不行?
<HTML>
<head>
<script type="text/javascript">
var startTime
var win
function linkTo(url)
{
startTime = new Date()
win = window.frames["tar"]
win.document.location.href = url
countTime()
}
function countTime()
{
if (win.document.readyState != "complete")
{
setTimeout(countTime, 1)
}
else
{
alert("页面加载耗时:" + (new Date() - startTime)/1000 + "秒")
}
}
</script>
</head><BODY>
<a href='#' onclick='linkTo("test.htm?s=http://community.csdn.net/Expert/TopicView1.asp?id=5287144")'>csdn</a>
<a href='#' onclick='linkTo("test.htm?s=http://www.163.com")'>163</a><br><br>
<iframe src="" name="tar"></iframe>
</BODY>
</HTML>test.htm
--------------------
<HTML>
<BODY>
<p id='urlText'></p>
<iframe id=tt src=""></iframe>
<script>
var url = document.location.search.split("?s=")[1]
window.frames["tt"].document.location.href = url
urlText.innerText = url
</script></BODY>
</HTML>
-----------------------
<script language="javascript">
var seconds=0;
function calculate(){
if(document.readyState!='complete'){seconds++;window.setTimeout('calculate()',10);}
else document.write('加载时间为'+(seconds/100)+'秒');
}
</script>
<body>
<script>calculate();</script>
<img src="http://today.java.net/images/tiles/111-nutch.gif" />
</body>
<script language="javascript">
var seconds=0;
function calculate(){
if(document.readyState!='complete'){seconds++;window.setTimeout('calculate()',10);}
else alert('加载时间为'+(seconds/100)+'秒');
}
</script>
<script>calculate();</script>
<iframe width=300 height=200 src="http://www.xinhuanet.com/" /><br>
</body>这个效果明显一点
<script language="javascript">
var seconds=0;
function calculate(){
if(document.readyState!='complete'){seconds++;window.setTimeout('calculate()',10);}
else document.getElementById('show').value='页面完成,加载时间为'+(seconds/100)+'秒';
}
</script><body>
<input name="show" type="text" id="show" value="正在加载,请稍等。" size="30" readOnly >
<br><script>calculate();</script>
<iframe width=300 height=200 src="http://www.xinhuanet.com/" /><br></body>