JScript能不能计算页面运行时间 在Onload事件里面获得当前时间,在onunload获得离开时间,减一下啦 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试一试我的代码吧<HTML><HEAD><TITLE>停留时间</TITLE></HEAD><SCRIPT LANGUAGE="JAVASCRIPT">var ap_name = navigator.appName;var ap_vinfo = navigator.appVersion;var ap_ver = parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));var time_start = new Date();var clock_start = time_start.getTime();var dl_ok=false;function init (){if(ap_name=="Netscape" && ap_ver>=3.0)dl_ok=true; return true;}function get_time_spent (){ var time_now = new Date();return((time_now.getTime() - clock_start)/1000); }function show_secs() // show the time user spent on the side{ var i_total_secs = Math.round(get_time_spent()); var i_secs_spent = i_total_secs % 60;var i_mins_spent = Math.round((i_total_secs-30)/60); var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_spent);var s_mins_spent = "" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);document.fm0.time_spent.value = s_mins_spent + ":" + s_secs_spent;window.setTimeout('show_secs()',1000); }</SCRIPT><BODY onLoad="init(); window.setTimeout('show_secs()',10);"><form name="fm0" onSubmit="0"><font size="-1"><I><FONT COLOR="#888888">停留时间:</FONT></I></font><br><INPUT type="text" name="time_spent" size=7 onFocus="this.blur()"></form></BODY></HTML> 原理一样,稍加修改即可,不知是否是你想要的。<HTML><HEAD><TITLE>打开时间</TITLE><script language="javascript">function makearray(n) {this.length = n;for(var i = 1; i <= n; i++) this[i] = 0;return this;}hexa = new makearray(16);for(var i = 0; i < 10; i++) hexa[i] = i; hexa[10]="a"; hexa[11]="b"; hexa[12]="c";hexa[13]="d"; hexa[14]="e"; hexa[15]="f";function hex(i) {if (i < 0) return "00";else if (i > 255) return "ff"; else return "" + hexa[Math.floor(i/16)] + hexa[i%16];}function setbgColor(r, g, b) { var hr = hex(r); var hg = hex(g); var hb = hex(b); document.bgColor = "#"+hr+hg+hb;}function fade(sr, sg, sb, er, eg, eb, step) { for(var i = 0; i <= step; i++) { setbgColor( Math.floor(sr * ((step-i)/step) + er * (i/step)), Math.floor(sg * ((step-i)/step) + eg * (i/step)), Math.floor(sb * ((step-i)/step) + eb * (i/step))); }}function fadein() {fade(255,0,0,0,0,255,100);fade(0,0,255,0,255,0,100);fade(0,255,0, 0,0,0, 100);}</script></HEAD><SCRIPT LANGUAGE="JAVASCRIPT">var ap_name = navigator.appName;var ap_vinfo = navigator.appVersion;var ap_ver = parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));var time_start = new Date();var clock_start = time_start.getTime();var dl_ok=false;function init (){if(ap_name=="Netscape" && ap_ver>=3.0)dl_ok=true; return true;}function get_time_spent (){ var time_now = new Date();return((time_now.getTime() - clock_start)/1000); }function show_secs() // show the time user spent on the side{ var i_total_secs = Math.round(get_time_spent()); var i_secs_spent = i_total_secs % 60;var i_mins_spent = Math.round((i_total_secs-30)/60); var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_spent);var s_mins_spent = "" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);document.fm0.time_spent.value = s_mins_spent + ":" + s_secs_spent;}//window.setTimeout('show_secs()',1000); </SCRIPT><BODY onLoad="init();"><form name="fm0" onSubmit="0"><font size="-1"><I><FONT COLOR="#888888">打开时间:</FONT></I></font><br><INPUT type="text" name="time_spent" size=7 onFocus="this.blur()"></form><script language="javascript">fadein();show_secs();</script></BODY></HTML> <html><head><script language=javascript>var t1 = new Date().getTime();</script></head><body onload=onload='window.status = "打开该网页一共花出 "+ (new Date().getTime()-t1)/1000 +" 秒钟!"'></body></html> 用于登录的弹出层的jquery插件,什么样的比较和呢 js关闭层问题,求大神指教啊,急~~~ 我做了一个鼠标放上去时就出现下拉菜单的程序 可是出了点问题 有直接写出对象名称的法吗? JS,如何在父窗口打开新页面? HTML里面能不能画直接 怎么美化javascript的弹出警告窗口? 怎样获得 combobox里面有几行 js按钮功能出错 td中换行问题 有一个文本域,我想让它里边的字显示为粗体,通过点击"加粗"按钮来实现,应该怎样写?谢谢 求代码(屏蔽源代码的),给高分
<HTML>
<HEAD>
<TITLE>停留时间</TITLE>
</HEAD>
<SCRIPT LANGUAGE="JAVASCRIPT">var ap_name = navigator.appName;
var ap_vinfo = navigator.appVersion;
var ap_ver = parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));
var time_start = new Date();
var clock_start = time_start.getTime();
var dl_ok=false;
function init (){
if(ap_name=="Netscape" && ap_ver>=3.0)
dl_ok=true;
return true;}
function get_time_spent (){
var time_now = new Date();
return((time_now.getTime() - clock_start)/1000); }
function show_secs() // show the time user spent on the side
{
var i_total_secs = Math.round(get_time_spent());
var i_secs_spent = i_total_secs % 60;
var i_mins_spent = Math.round((i_total_secs-30)/60);
var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_spent);
var s_mins_spent = "" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);
document.fm0.time_spent.value = s_mins_spent + ":" + s_secs_spent;
window.setTimeout('show_secs()',1000); }</SCRIPT>
<BODY onLoad="init(); window.setTimeout('show_secs()',10);">
<form name="fm0" onSubmit="0">
<font size="-1"><I><FONT COLOR="#888888">停留时间:</FONT></I></font><br>
<INPUT type="text" name="time_spent" size=7 onFocus="this.blur()">
</form>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>打开时间</TITLE>
<script language="javascript">
function makearray(n) {
this.length = n;
for(var i = 1; i <= n; i++)
this[i] = 0;
return this;}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
hexa[i] = i;
hexa[10]="a";
hexa[11]="b";
hexa[12]="c";
hexa[13]="d";
hexa[14]="e";
hexa[15]="f";
function hex(i) {
if (i < 0)
return "00";
else if (i > 255)
return "ff";
else return "" + hexa[Math.floor(i/16)] + hexa[i%16];}
function setbgColor(r, g, b) {
var hr = hex(r);
var hg = hex(g);
var hb = hex(b);
document.bgColor = "#"+hr+hg+hb;
}function fade(sr, sg, sb, er, eg, eb, step) {
for(var i = 0; i <= step; i++) {
setbgColor( Math.floor(sr * ((step-i)/step) + er * (i/step)),
Math.floor(sg * ((step-i)/step) + eg * (i/step)), Math.floor(sb *
((step-i)/step) + eb * (i/step))); }}function fadein() {
fade(255,0,0,0,0,255,100);
fade(0,0,255,0,255,0,100);
fade(0,255,0, 0,0,0, 100);}
</script>
</HEAD>
<SCRIPT LANGUAGE="JAVASCRIPT">var ap_name = navigator.appName;
var ap_vinfo = navigator.appVersion;
var ap_ver = parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));
var time_start = new Date();
var clock_start = time_start.getTime();
var dl_ok=false;
function init (){
if(ap_name=="Netscape" && ap_ver>=3.0)
dl_ok=true;
return true;}
function get_time_spent (){
var time_now = new Date();
return((time_now.getTime() - clock_start)/1000); }
function show_secs() // show the time user spent on the side
{
var i_total_secs = Math.round(get_time_spent());
var i_secs_spent = i_total_secs % 60;
var i_mins_spent = Math.round((i_total_secs-30)/60);
var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_spent);
var s_mins_spent = "" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);
document.fm0.time_spent.value = s_mins_spent + ":" + s_secs_spent;
}
//window.setTimeout('show_secs()',1000);
</SCRIPT>
<BODY onLoad="init();">
<form name="fm0" onSubmit="0">
<font size="-1"><I><FONT COLOR="#888888">打开时间:</FONT></I></font><br>
<INPUT type="text" name="time_spent" size=7 onFocus="this.blur()">
</form>
<script language="javascript">
fadein();
show_secs();
</script>
</BODY>
</HTML>
<head>
<script language=javascript>var t1 = new Date().getTime();</script>
</head><body onload=onload='window.status = "打开该网页一共花出 "+ (new Date().getTime()-t1)/1000 +" 秒钟!"'></body>
</html>