javascript

位置:IT落伍者 >> javascript >> 浏览文章

用JavaScript查看一些用户信息


发布日期:2021年09月27日
 
用JavaScript查看一些用户信息
检测浏览器版本

<Script Language=JavaScript>

<!

documentwrite(navigatorappVersion)

//>

</script>

记住来访次数

<SCRIPT LANGUAGE=JavaScript>

<!

var caution = false

function setCookie(name value expires path domain secure) {

var curCookie = name + = + escape(value) +

((expires) ? ; expires= + expirestoGMTString() : ) +

((path) ? ; path= + path : ) +

((domain) ? ; domain= + domain : ) +

((secure) ? ; secure : )

if (!caution || (name + = + escape(value))length <= )

okie = curCookie

else

if (confirm(Cookie exceeds KB and will be cut!))

okie = curCookie

}

function getCookie(name) {

var prefix = name + =

var cookieStartIndex = okieindexOf(prefix)

if (cookieStartIndex == )

return null

var cookieEndIndex = okieindexOf(; cookieStartIndex + prefixlength)

if (cookieEndIndex == )

cookieEndIndex = okielength

return unescape(okiesubstring(cookieStartIndex + prefixlength cookieEndIndex))

}

function deleteCookie(name path domain) {

if (getCookie(name)) {

okie = name + = +

((path) ? ; path= + path : ) +

((domain) ? ; domain= + domain : ) +

; expires=Thu Jan :: GMT

}

}

function fixDate(date) {

var base = new Date()

var skew = basegetTime()

if (skew > )

datesetTime(dategetTime() skew)

}

var now = new Date()

fixDate(now)

nowsetTime(nowgetTime() + * * * * )

var visits = getCookie(counter)

if (!visits)

visits =

else

visits = parseInt(visits) +

setCookie(counter visits now)

documentwrite(您已来这儿 + visits + )

// >

</SCRIPT>

你从哪个网页访问过来

<Script Language=JavaScript>

documentwrite(documentreferrer)

</SCRIPT>

最后更新日期

<script language=JavaScript>

<!hide script from old browsers

documentwrite(This page has been updated: + documentlastModified + )

// end hiding >

</script>

输入姓名至欢迎词

把以下代码放在<head></head>之间

<script>

var name=prompt(YOUR PROMPT MESSAGEANY INITAL VALUE)

</script>

</font>

把以下代码放在HTML文件中

<center>

<font color=green>

<script>documentwrite(name);</script>

</font>

其它要输出信息</center>

</font>

记住来访时间

<HTML>

<HEAD>

<TITLE>Name Visits Last Visit</TITLE>

<SCRIPT LANGUAGE=JavaScript>

<! Begin

var expDays = ;

var exp = new Date();

expsetTime(expgetTime() + (expDays****));

function Who(info){

var VisitorName = GetCookie(VisitorName)

if (VisitorName == null) {

VisitorName = prompt(您的尊姓大名);

SetCookie (VisitorName VisitorName exp);

}

return VisitorName;

}

function When(info){

var rightNow = new Date()

var WWHTime = ;

WWHTime = GetCookie(WWhenH)

WWHTime = WWHTime *

var lastHereFormatting = new Date(WWHTime);

var intLastVisit = (lastHereFormattinggetYear() * )+

(lastHereFormattinggetMonth() * ) + lastHereFormattinggetDate()

var lastHereInDateFormat = + lastHereFormatting;

var dayOfWeek = lastHereInDateFormatsubstring()

var dateMonth = lastHereInDateFormatsubstring()

var timeOfDay = lastHereInDateFormatsubstring()

var year = lastHereInDateFormatsubstring()

var WWHText = dayOfWeek + + dateMonth + at + timeOfDay

SetCookie (WWhenH rightNowgetTime() exp)

return WWHText

}

function Count(info){

var WWHCount = GetCookie(WWHCount)

if (WWHCount == null) {

WWHCount = ;

}

else{

WWHCount++;

}

SetCookie (WWHCount WWHCount exp);

return WWHCount;

}

function set(){

VisitorName = prompt(Who are you?);

SetCookie (VisitorName VisitorName exp);

SetCookie (WWHCount exp);

SetCookie (WWhenH exp);

}

function getCookieVal (offset) {

var endstr = okieindexOf (; offset);

if (endstr == )

endstr = okielength;

return unescape(okiesubstring(offset endstr));

}

function GetCookie (name) {

var arg = name + =;

var alen = arglength;

var clen = okielength;

var i = ;

while (i < clen) {

var j = i + alen;

if (okiesubstring(i j) == arg)

return getCookieVal (j);

i = okieindexOf( i) + ;

if (i == ) break;

}

return null;

}

function SetCookie (name value) {

var argv = SetCookiearguments;

var argc = SetCookieargumentslength;

var expires = (argc > ) ? argv[] : null;

var path = (argc > ) ? argv[] : null;

var domain = (argc > ) ? argv[] : null;

var secure = (argc > ) ? argv[] : false;

okie = name + = + escape (value) +

((expires == null) ? : (; expires= + expirestoGMTString())) +

((path == null) ? : (; path= + path)) +

((domain == null) ? : (; domain= + domain)) +

((secure == true) ? ; secure : );

}

function DeleteCookie (name) {

var exp = new Date();

expsetTime (expgetTime() );

var cval = GetCookie (name);

okie = name + = + cval + ; expires= + exptoGMTString();

}

//End >

</SCRIPT>

</HEAD>

<BODY BGCOLOR=#ffffff vlink=#ff>

<! Demonstration >

<CENTER>

<SCRIPT LANGUAGE=JavaScript>

if (Count()==)

{

documentwrite(您好! + Who() + 您首次来这儿请多提宝贵意见);

}

else

{

documentwrite(您好! + Who() + 您已来这儿 + Count() + 次了最后一次在 + When() +);

}

</SCRIPT>

</CENTER>

</BODY>

</HTML>               

上一篇:网页JS浮动提示效果

下一篇:通过Javascript代码来使用鼠标的中键