真的不好意思:楼主借宝地一用了。 to yellowzhong(程序黄了) to mickey_uuu() 我的理解很浅薄。我是这样理解的。首先,无刷新的实现是基于socket协议的,用户和服务的socket是不断的,始终处于一种接受状态,形象的就是相当于你访问一个很大的网页,服务器会不断的把信息给你,明显的表现就是你的状态栏一直处于打开网页的状态。 不知道说什么了~~~~ socket server 是自己的不断监听用户的某一端口。有变化的数据,就把变化传给全部的用户。实现了聊天。 网上有好多这方面的资料。google
简单了JAVASCRIT SERVER PUSH 我刚才去看了一下,没有意义,你能建立几个SOCKET能,还要每个SOCKET起一个监视进程,唉那服务器牛的。 我看除非是局域网,除非是视频通信,否则,拖跨你服务器。
好东西大家分享呀! ManFirst(ManFirst)的方法真好。SERVER PUSH 应该有点点用的。呵呵~~~ ManFirst(ManFirst) 真的是牛人呀 看了一下就知道没意义。多亏我没花时间去研究 SERVER PUSH 谢谢点拨。
给你们一个我写的经典JAVASCRIPT不另收费。 ------ <html xmlns:v = "urn:schemas-microsoft-com:vml"> <head> <script language="JavaScript"> var FromHeight=200; var FromWidth=FromHeight; var OpenMill=true; //cut a second to 10 var ChangeMolde=false;//if change var BeginDrag=false; var rectHour; var rectSecond; var rectMinter; var ClockTime;// var HourfillColor;//object of hour point. var MinfillColor;//object of minuter point. var DragObject="none";//changed object. var OldPointMin=0;//take old Minuters Have point to see back or forward var MondifyHour=0;//When changed,the time is. nUnit="px";//input the unit. function MoldeChanged() { if (!ChangeMolde) { var Now = new Date(); ChangeMolde=true; document.ondragstart=new Function ("return false"); document.onselectstart=new Function ("return false"); rectHour.onmouseover=OverPoint; rectHour.onmouseout=OutPoint; rectHour.onmousedown=Function ("DownPoint('rectHour')"); rectMinter.onmouseover=OverPoint; rectMinter.onmouseout=OutPoint; rectMinter.onmousedown=Function ("DownPoint('rectMinter')");
} else { ChangeMolde=false; rectHour.onmouseover=new Function ("return false"); rectHour.onmouseout=new Function ("return false"); rectHour.onmousedown=new Function ("return false"); rectMinter.onmouseover=new Function ("return false"); rectMinter.onmouseout=new Function ("return false"); rectMinter.onmousedown=new Function ("return false"); document.onclick=new Function ("return false"); document.ondragstart=new Function ("return false"); document.onselectstart=new Function ("return false"); ClockSpan.onmousemove=new Function ("return false"); SetTime(0); }
} function SetTime(SetEvent) {
var Now = new Date(); var Seconds = Now.getSeconds(); var Minutes = Now.getMinutes(); var Hours = Now.getHours(); var minSeconds=Now.getUTCMilliseconds(); ClockTime.value=Hours+":"+Minutes+","+Seconds; if (!OpenMill) minSeconds=0; rectSecond.rotation=Seconds*6+minSeconds*0.006; rectMinter.rotation=Minutes*6+Seconds/60; if (Hours>=12) Hours=Hours-12; rectHour.rotation=Hours*30+Minutes/2; HourfillColor.angle=Hours*30+Minutes/2; MinfillColor.angle=Minutes*6+Seconds/60;
if (!ChangeMolde) { window.clearTimeout(ColokInterval); var ColokInterval=window.setTimeout("SetTime(0)",100); }}function MovePoint() {
不过这样会屏幕会不断的闪,
有一种方式就是用frame. 分左右两个frameset.左面隐藏不断刷新,右面显示 当左面变化刷新显示。
我手上没有现成的,我也的现写,还不如你自己写,对吧。
HOHO~~~~
to jianlin(妞妞)
由左边的隐藏页面不断刷新来扑捉变化。有变化刷新右面的页面显示。无变化,则不刷新右面得页面。给用户看的只是右面的页面。
也就现在应用很广的server push技术。就是无刷新聊天室。
我用过我说的那种方法,原理就是巧妙的用了frame.
我知道了,就是说在不是特别频繁的变化的情况下,如果采用frame的这种方式就不用每次都刷新,而只是在数据变化的情况下刷新,而不用这种方式,就每次都会去刷新一次页面,所以就会经常闪烁,我这样理解对吗?多谢指导
每隔一秒刷新一次,绝不会闪烁
realby(忽然睡了)
状态栏里是闪的吧不闪 状态栏是主页面的,你不断刷新的是frame的frameset.
index.htm
left.htm
right.htm
看到的是index.htm的状态栏,不断刷left.htm,left变 right变。
我们看到的内容是right的内容.
在下对server push技术颇感兴趣,不过只是听过一两遍而已,想问阁下有这方面的资料吗?
</span><iframe src="tmp.jsp" id=tmpFrame>
</iframe>tmp.jsp
------
<html>
<META HTTP-EQUIV="REFRESH" CONTENT="x; URL=tmp.jsp"> <!--用一下哈哈--!>
<%
....
String objValue="你要显示的";
%>
</html>
<script language=JavaScript>
parent.document.all.palySan.innerHTML="<%=objValue%>"
</script>------
</iframe>
更正一下,这样就看不见刷新桢了,你可以看CPU显示的和不显示的CPU相差很大。
再问一个简单的问题,要怎么能使frame隐藏呢?谢了
哈哈,这么多高手,太感谢了
to yellowzhong(程序黄了)
to mickey_uuu()
我的理解很浅薄。我是这样理解的。首先,无刷新的实现是基于socket协议的,用户和服务的socket是不断的,始终处于一种接受状态,形象的就是相当于你访问一个很大的网页,服务器会不断的把信息给你,明显的表现就是你的状态栏一直处于打开网页的状态。
不知道说什么了~~~~ socket server 是自己的不断监听用户的某一端口。有变化的数据,就把变化传给全部的用户。实现了聊天。 网上有好多这方面的资料。google
SERVER PUSH 我刚才去看了一下,没有意义,你能建立几个SOCKET能,还要每个SOCKET起一个监视进程,唉那服务器牛的。
我看除非是局域网,除非是视频通信,否则,拖跨你服务器。
ManFirst(ManFirst)的方法真好。SERVER PUSH 应该有点点用的。呵呵~~~
ManFirst(ManFirst) 真的是牛人呀 看了一下就知道没意义。多亏我没花时间去研究
SERVER PUSH 谢谢点拨。
见笑了,我刚才参考你的代码改了一下我的,但是有问题,我现在想问一下你,你的tmp.jsp是------以上的代码,还是以下的代码。我的理解应该是以上的代码,然后以下的是显示用的jsp文件,是吗?小妹刚学,简单的问题希望不要笑话
再to blue999star
再问一个简单的问题,要怎么能使frame隐藏呢?谢了
------
<html xmlns:v = "urn:schemas-microsoft-com:vml">
<head>
<script language="JavaScript">
var FromHeight=200;
var FromWidth=FromHeight;
var OpenMill=true; //cut a second to 10
var ChangeMolde=false;//if change
var BeginDrag=false;
var rectHour;
var rectSecond;
var rectMinter;
var ClockTime;//
var HourfillColor;//object of hour point.
var MinfillColor;//object of minuter point.
var DragObject="none";//changed object.
var OldPointMin=0;//take old Minuters Have point to see back or forward
var MondifyHour=0;//When changed,the time is.
nUnit="px";//input the unit.
function MoldeChanged()
{
if (!ChangeMolde)
{
var Now = new Date();
ChangeMolde=true;
document.ondragstart=new Function ("return false");
document.onselectstart=new Function ("return false");
rectHour.onmouseover=OverPoint;
rectHour.onmouseout=OutPoint;
rectHour.onmousedown=Function ("DownPoint('rectHour')");
rectMinter.onmouseover=OverPoint;
rectMinter.onmouseout=OutPoint;
rectMinter.onmousedown=Function ("DownPoint('rectMinter')");
}
else
{
ChangeMolde=false;
rectHour.onmouseover=new Function ("return false");
rectHour.onmouseout=new Function ("return false");
rectHour.onmousedown=new Function ("return false");
rectMinter.onmouseover=new Function ("return false");
rectMinter.onmouseout=new Function ("return false");
rectMinter.onmousedown=new Function ("return false");
document.onclick=new Function ("return false");
document.ondragstart=new Function ("return false");
document.onselectstart=new Function ("return false");
ClockSpan.onmousemove=new Function ("return false");
SetTime(0);
}
}
function SetTime(SetEvent)
{
var Now = new Date();
var Seconds = Now.getSeconds();
var Minutes = Now.getMinutes();
var Hours = Now.getHours();
var minSeconds=Now.getUTCMilliseconds();
ClockTime.value=Hours+":"+Minutes+","+Seconds;
if (!OpenMill)
minSeconds=0;
rectSecond.rotation=Seconds*6+minSeconds*0.006;
rectMinter.rotation=Minutes*6+Seconds/60;
if (Hours>=12)
Hours=Hours-12;
rectHour.rotation=Hours*30+Minutes/2;
HourfillColor.angle=Hours*30+Minutes/2;
MinfillColor.angle=Minutes*6+Seconds/60;
if (!ChangeMolde)
{
window.clearTimeout(ColokInterval);
var ColokInterval=window.setTimeout("SetTime(0)",100);
}}function MovePoint()
{
var ModifyMinuter;
if (DragObject!="none")
{
if(DragObject=="rectHour")
{
if (((window.event.y-0.5*FromHeight)<0) && ((window.event.clientX-0.5*FromHeight)>=0))
{
HourfillColor.angle=Math.atan2((window.event.clientX-0.5*FromHeight),(0.5*FromHeight-window.event.y))*(180/Math.PI);
rectHour.rotation=Math.atan2((window.event.clientX-0.5*FromHeight),(0.5*FromHeight-window.event.y))*(180/Math.PI);
}
else if(((window.event.y-0.5*FromHeight)>=0) && ((window.event.clientX-0.5*FromHeight)>0))
{
HourfillColor.angle=90+Math.atan2((window.event.y-0.5*FromHeight),(window.event.clientX-0.5*FromHeight))*(180/Math.PI);
rectHour.rotation=90+Math.atan2((window.event.y-0.5*FromHeight),(window.event.clientX-0.5*FromHeight))*(180/Math.PI);
}
else if(((window.event.y-0.5*FromHeight)>0) && ((window.event.clientX-0.5*FromHeight)<=0))
{
HourfillColor.angle=180+Math.atan2((0.5*FromHeight-window.event.clientX),(window.event.y-0.5*FromHeight))*(180/Math.PI);
rectHour.rotation=180+Math.atan2((0.5*FromHeight-window.event.clientX),(window.event.y-0.5*FromHeight))*(180/Math.PI);
}
else if(((window.event.y-0.5*FromHeight)<=0) && ((window.event.clientX-0.5*FromHeight)<0))
{
HourfillColor.angle=360-Math.atan2((0.5*FromHeight-window.event.clientX),(0.5*FromHeight-window.event.y))*(180/Math.PI);
rectHour.rotation=360-Math.atan2((0.5*FromHeight-window.event.clientX),(0.5*FromHeight-window.event.y))*(180/Math.PI);
}
MondifyMinuter=Math.floor((rectHour.rotation-Math.floor(rectHour.rotation/30)*30)*2);
OldPointMin=MondifyMinuter;
}
else if(DragObject=="rectMinter")
{
var NowPointMin=0;
if (((window.event.y-0.5*FromHeight)<0) && ((window.event.clientX-0.5*FromHeight)>=0))
{
if (OldPointMin>45)
{
rectHour.rotation=Math.floor(rectHour.rotation/30)*30+30;
}
else
{
MinfillColor.angle=Math.atan2((window.event.clientX-0.5*FromHeight),(0.5*FromHeight-window.event.y))*(180/Math.PI);
rectMinter.rotation=Math.atan2((window.event.clientX-0.5*FromHeight),(0.5*FromHeight-window.event.y))*(180/Math.PI);
NowPointMin=Math.atan2((window.event.clientX-0.5*FromHeight),(0.5*FromHeight-window.event.y))*(180/Math.PI);
rectHour.rotation=Math.floor(rectHour.rotation/30)*30+NowPointMin/12;
}
OldPointMin=NowPointMin/6;
}
else if(((window.event.y-0.5*FromHeight)>=0) && ((window.event.clientX-0.5*FromHeight)>0))
{
MinfillColor.angle=90+Math.atan2((window.event.y-0.5*FromHeight),(window.event.clientX-0.5*FromHeight))*(180/Math.PI);
rectMinter.rotation=90+Math.atan2((window.event.y-0.5*FromHeight),(window.event.clientX-0.5*FromHeight))*(180/Math.PI);
NowPointMin=90+Math.atan2((window.event.y-0.5*FromHeight),(window.event.clientX-0.5*FromHeight))*(180/Math.PI);
rectHour.rotation=Math.floor(rectHour.rotation/30)*30+NowPointMin/12;
OldPointMin=NowPointMin/6;
}
else if(((window.event.y-0.5*FromHeight)>0) && ((window.event.clientX-0.5*FromHeight)<=0))
{
MinfillColor.angle=180+Math.atan2((0.5*FromHeight-window.event.clientX),(window.event.y-0.5*FromHeight))*(180/Math.PI);
rectMinter.rotation=180+Math.atan2((0.5*FromHeight-window.event.clientX),(window.event.y-0.5*FromHeight))*(180/Math.PI);
NowPointMin=180+Math.atan2((0.5*FromHeight-window.event.clientX),(window.event.y-0.5*FromHeight))*(180/Math.PI);
rectHour.rotation=Math.floor(rectHour.rotation/30)*30+NowPointMin/12;
OldPointMin=NowPointMin/6;
}
else if(((window.event.y-0.5*FromHeight)<=0) && ((window.event.clientX-0.5*FromHeight)<0))
{
if (OldPointMin<15)
{
rectHour.rotation=Math.floor(rectHour.rotation/30)*30-30;
}
MinfillColor.angle=360-Math.atan2((0.5*FromHeight-window.event.clientX),(0.5*FromHeight-window.event.y))*(180/Math.PI);
rectMinter.rotation=360-Math.atan2((0.5*FromHeight-window.event.clientX),(0.5*FromHeight-window.event.y))*(180/Math.PI);
NowPointMin=360-Math.atan2((0.5*FromHeight-window.event.clientX),(0.5*FromHeight-window.event.y))*(180/Math.PI);
rectHour.rotation=Math.floor(rectHour.rotation/30)*30+NowPointMin/12;
OldPointMin=NowPointMin/6;
}
MondifyMinuter=Math.floor((rectHour.rotation-Math.floor(rectHour.rotation/30)*30)*2);
} MondifyHour=Math.floor(rectHour.rotation/30);
if (MondifyHour<0)
{
MondifyHour=12-Math.abs(MondifyHour-Math.ceil(MondifyHour/12)*12);
}
document.all("MondifyTime").value=Math.floor(rectHour.rotation/30)+","+MondifyHour+":"+MondifyMinuter;
}
}
function OutPoint()
{
if(!BeginDrag)
document.body.style.cursor="default";
}
function OverPoint()
{
document.body.style.cursor="hand";
}
function DownPoint(nstr)
{
BeginDrag=true;
DragObject=nstr;
document.body.onmousemove=MovePoint;
document.body.onmouseup=DragStop;
}
{
BeginDrag=false;
OutPoint();
if (DragObject=="rectHour")
{
rectMinter.rotation=(rectHour.rotation-Math.floor(rectHour.rotation/30)*30)*12;
}
OldPointMin=0;
DragObject="none";
document.body.onmouseup="";
document.body.onmousemove="";
}
function InitFrom()
{
var imgbg=document.createElement("img");
imgbg.src="image/Watchbg.gif";
imgbg.style.width=FromHeight+nUnit;
imgbg.style.height=FromWidth+nUnit;
ClockSpan.appendChild(imgbg);
//center
var ClockCenter=document.createElement("v:oval");
ClockCenter.style.position="absolute";
ClockCenter.style.top=0.47*FromHeight+nUnit;
ClockCenter.style.left=0.47*FromWidth+nUnit;
ClockCenter.style.width=0.06*FromHeight+nUnit;
ClockCenter.style.height=0.06*FromHeight+nUnit;
ClockCenter.style.zIndex="4";
ClockCenter.strokecolor= '#9591EE';
var fileColor=document.createElement("v:fill");
fileColor.type='gradient';
fileColor.color2 = 'green';
fileColor.angle = '1200';
ClockCenter.appendChild(fileColor);
ClockSpan.appendChild(ClockCenter);
//hourspoint
rectHour=document.createElement("v:shape");
rectHour.coordorigin="0 0";
rectHour.coordsize="1000 1000";
rectHour.style.position="absolute";
rectHour.style.width=FromHeight+nUnit;
rectHour.style.height=FromWidth+nUnit;
rectHour.style.top="0"+nUnit;
rectHour.style.left="0"+nUnit;
rectHour.fillcolor = '#000000';
rectHour.strokecolor= '#9591EE';
rectHour.style.zIndex="2";
rectHour.path = 'm 490,300 l 510,300, 520,560, 480,560 xe';
var RectShaw=document.createElement("v:shadow");
RectShaw.on='t';
RectShaw.type='single';
RectShaw.offset=0.015*FromHeight+nUnit+','+0.015*FromHeight+nUnit;
rectHour.appendChild(RectShaw);
HourfillColor=document.createElement("v:fill");
HourfillColor.type='gradient';
HourfillColor.color2 = '#8380FF';
HourfillColor.angle = '180';
rectHour.appendChild(HourfillColor);
ClockSpan.appendChild(rectHour);
//minterpoint
rectMinter=document.createElement("v:shape");
rectMinter.coordorigin="0 0";
rectMinter.coordsize="1000 1000";
rectMinter.style.position="absolute";
rectMinter.style.width=FromHeight+nUnit;
rectMinter.style.height=FromWidth+nUnit;
rectMinter.style.top="0"+nUnit;
rectMinter.style.left="0"+nUnit;
rectMinter.fillcolor = '#000000';
rectMinter.strokecolor= '#9591EE';
rectMinter.style.zIndex="2";
rectMinter.path = 'm 490,200 l 510,200, 520,600, 480,600 xe';
RectShaw=document.createElement("v:shadow");
RectShaw.on='t';
RectShaw.type='single';
RectShaw.offset=0.015*FromHeight+nUnit+','+0.015*FromHeight+nUnit;
rectMinter.appendChild(RectShaw);
MinfillColor=document.createElement("v:fill");
MinfillColor.type='gradient';
MinfillColor.color2 = '#8380FF';
MinfillColor.angle = '180';
rectMinter.appendChild(MinfillColor);
ClockSpan.appendChild(rectMinter);
//secondpoint
rectSecond=document.createElement("v:shape");
rectSecond.coordorigin="0 0";
rectSecond.coordsize="1000 1000";
rectSecond.style.position="absolute";
rectSecond.style.width=FromHeight+nUnit;
rectSecond.style.height=FromWidth+nUnit;
rectSecond.style.top="0"+nUnit;
rectSecond.style.left="0"+nUnit;
rectSecond.fillcolor = '#000000';
rectSecond.strokecolor= '#000000';
rectSecond.StrokeWidth="0"+nUnit;
rectSecond.style.zIndex="2";
rectSecond.path = 'm 495,150 l 505,150, 505,600, 495,600 xe';
RectShaw=document.createElement("v:shadow");
RectShaw.on='t';
RectShaw.type='single';
RectShaw.offset=0.015*FromHeight+nUnit+','+0.015*FromHeight+nUnit;
rectSecond.appendChild(RectShaw);
ClockSpan.appendChild(rectSecond);
//set first time
ClockTime=document.createElement("input");
ClockTime.type="text";
ClockTime.style.top=FromHeight;
ClockTime.style.left=FromWidth;
ClockSpan.appendChild(ClockTime);
if (!ChangeMolde)
{
document.ondragstart=new Function ("return false");
document.onselectstart=new Function ("return false");
SetTime(0);
}
}</script>
<style>
v\:* { behavior: url(#default#VML); }</style>
</head>
<body bgcolor=Gainsboro onload="InitFrom()">
<span id=ClockSpan name=ClockSpan style="position:absolute;width:100;height:100;top:0pt;left:0pt"></span><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR>
<INPUT type="button" onclick="MoldeChanged()" value="Button" id=button1 name=button1>
<INPUT type="text" id=MondifyTime name=MondifyTime>
</body>
</html>
————————
放在主JSP中啊,
就是你那个包含IFRAME的页面
BODY.JSP
***
不刷新的:<span id=palySan >
</span><iframe src="tmp.jsp" id=tmpFrame>
</iframe>
*****
tmp.jsp
*****
------
<html>
<META HTTP-EQUIV="REFRESH" CONTENT="x; URL=tmp.jsp"> <!--用一下哈哈--!>
<%
....
String objValue="你要显示的";
%>
</html>
<script language=JavaScript>
parent.document.all.palySan.innerHTML="<%=objValue%>"
</script>------
把左边的列设成0 就行了
cols="0,*" to ManFirst(ManFirst)
javascript 牛人呀,有时间看看你的代码,完成了什么功能?save
能不能给点注释呀!!
好长好长,o 的眼睛都看花了,谢谢。
点缀的东西嘛。。
学JAVA就把多线程学好吧。
不好意思,iframe怎么用。我现在可以显示了,但是要显示的东西只有一小块,其他地方都是空的,为什么?
to ManFirst
不好意思,iframe怎么用。我现在可以显示了,但是要显示的东西只有一小块,其他地方都是空的,为什么?
********
不明白,
IFRAME内部帧,
FRAMES框架也。