⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windowjump_source.html

📁 this gives details of the network programming
💻 HTML
字号:
<HEAD><TITLE>Source for Moving Browser</TITLE><LINK rel=stylesheet type=text/css HREF=../../style/jsdemo.css></HEAD><BODY BGCOLOR=#CCCCCC MARGINHEIGHT=0 MARGINWIDTH=0 TOPMARGIN=0  LEFTMARGIN=0><TABLE bgColor=#8899aa border=0 cellPadding=4 cellSpacing=0 width=100%>  <TR>    <TD class=title>&nbsp NetProg 2002: Source for Moving Browser </TD> </TR>  <TR bgColor=black height=10><TD CLASS=menu> </TD></TR></TABLE><DIV CLASS=page><BR><BR><P><CENTER><TABLE BORDER=0 BGCOLOR=#8899aa CELLPADDING=5><TR><TD><TABLE bgcolor=white BORDER=0 CELLPADDING=10><TR><TD><PRE class=codebox>&lt;HEAD>
&lt;TITLE>Netprog JavaScript Demo - Moving Browser&lt;/TITLE>


&lt;SCRIPT LANGUAGE=JavaScript><SPAN CLASS=code>
&lt;!--
// move moves the position of the window
// it's current location. 
// positive xinc will move to the right (neg to the left)
// positive yinc will move down (neg up)

function move( xinc, yinc ) {

    var jsize=20;
    window.moveBy(jsize*xinc,jsize*yinc);
}

// random jump to anywhere

function hjump() {
    xpos = Math.random() * 600
    ypos = Math.random() * 400
    window.moveTo(xpos,ypos);
}

// variable used to keep track of when the game is running
var running=0;

// start up the game 
function hyperspace_game() {
    running=1;
    hyperspace_move();
}

// stop the game
function stop_hyperspace_game() {
    running=0;
}

// make a single game move by moving the image to a random
// location and then setting up to call this routine again
// after some delay. The delay before the next call is 
// based on the value of the speed field (the user can change).
function hyperspace_move() {
    var delay = document.frm.speed.value;
    if (delay &lt; 500) {
        document.frm.speed.value = 500;
    }
    if (running == 1) {
        hjump();
        setTimeout("hyperspace_move()",delay);
    }
}
// -->
</SPAN>&lt;/SCRIPT>
&lt;/HEAD>

&lt;BODY BGCOLOR=WHITE onUnload="<SPAN CLASS=code>restore()</SPAN>">

&lt;TABLE HEIGHT=380 WIDTH=200 BORDER=2>
&lt;TD BGCOLOR=CYAN>
&lt;FORM Name=frm>

&lt;CENTER>Move the browser&lt;/CENTER>&lt;BR>
&lt;TABLE>
&lt;TR ALIGN=CENTER>
  &lt;TD>&nbsp&lt;/TD>
  &lt;TD>&lt;INPUT TYPE=BUTTON Name=up  WIDTH=50 Value="Up" onClick="<SPAN CLASS=code>move(0,-1)</SPAN>">&lt;/TD>
  &lt;TD>&nbsp&lt;/TD>
&lt;/TR>

&lt;TR>
&lt;TD>&lt;INPUT TYPE=BUTTON WIDTH=50 Name=left Value="Left" onClick="<SPAN CLASS=code>move(-1,0)</SPAN>">&lt;/TD>
&lt;TD>&nbsp&lt;/TD>
&lt;TD>&lt;INPUT TYPE=BUTTON  WIDTH=50 Name=right Value="Right" onClick="<SPAN CLASS=code>move(1,0)</SPAN>">&lt;/TD>
&lt;/TR>

&lt;TR>
  &lt;TD>&nbsp&lt;/TD>
  &lt;TD>&lt;INPUT TYPE=BUTTON  WIDTH=50 Name=down Value="Down" onClick="<SPAN CLASS=code>move(0,1)</SPAN>">&lt;/TD>
  &lt;TD>&nbsp&lt;/TD>
&lt;/TR>
&lt;/TABLE>
&lt;P>
&lt;CENTER>
&lt;INPUT TYPE=BUTTON Name=jump Value="Random Jump" onClick="<SPAN CLASS=code>hjump()</SPAN>">
&lt;/CENTER>

&lt;HR>
&lt;CENTER>Play the chase game&lt;/CENTER>&lt;BR>
&lt;CENTER>
&lt;INPUT TYPE=BUTTON WIDTH=70 Name=chase Value="Start" onClick="<SPAN CLASS=code>hyperspace_game()</SPAN>">
&lt;INPUT TYPE=BUTTON WIDTH=70 Name=chase Value="Stop" onClick="<SPAN CLASS=code>stop_hyperspace_game()</SPAN>">
&lt;/CENTER>
&lt;BR>
Speed : &lt;INPUT TYPE=TEXT SIZE=5 Name=speed>&lt;BR>
&lt;HR>
&lt;/FORM>

&lt;/TD>
&lt;/TR>&lt;/TABLE>

&lt;SCRIPT><SPAN CLASS=code>
// save the initial window size (so we can restore it)
savewidth =  window.innerWidth;
saveheight = window.innerHeight;

function restore() {
  // Change the window size to the original values
  window.innerWidth=savewidth;
  window.innerHeight=saveheight;
}


// Change the window size to hold the controls only
//window.innerWidth=220;
//window.innerHeight=400;
window.resizeTo(300,600);
// initialize the game speed field to 2000
document.frm.speed.value=2000;


</SPAN>&lt;/SCRIPT>
&lt;/BODY></PRE></TD></TR></TABLE></TD></TR></TABLE></CENTER></DIV>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -