漫漫技术人生路

C#

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 function newO()
    {
      window.open("Default.aspx?name='rtyt'",'');
    }


function requestString(val)
{
  var q= unescape(location.search.substr(1)).split('&');//frist split
  
  for(var i=0;i<q.length;i++)
  {
    var t= q[i].split('=');//second split
   
    if(t[0].toLowerCase()==val.toLowerCase()) alert(t[1]);
  }

}
<body onload="requestString('name')">

var newWindow=window.open('', 'TestWindow', 'width=200,height=200');
newWindow.document.write('This window will close in 2 seconds');
setTimeout(function(){ newWindow.close(); }, 2000);

setTimeout will execute your code one time after the time has elapsed. setInterval will continue to execute your code after each interval. Set to 5,000, setInterval would execute your code every 5 seconds.

There are two other functions, clearTimeout and clearInterval that cancel Timeouts or Intervals you have set. In order to do this, however, you need to have a reference to the setTimeout or setInterval call, i.e:

var myTimeout = setTimeout("alert('Hi!');", 500);
clearTimeout(myTimeout);

If you did not save the reference, the myTimeout variable, there is no way to clear the Timeout or Interval. Now let's take a look at an example of this in action:
function createTimeout(text, time){
    setTimeout("alert('"+text+"');", time);
}


var intervals = [];
function createInterval(text, time){
    // store the interval in intervals array
    intervals.push(setInterval("alert('"+text+"');", time));
}


function tut5(){
    if(intervals.length==0) return;
    // clear the last interval in intervals array
    clearInterval(intervals.pop());
}
document.write('The URL of the parent window is: '+window.opener.location);

You have already seen various properties of the document object being used. document.forms, for instance, returns an array of all forms on the page. There are several properties similiar to this:

PropertyDescriptionProperty.length value on this page
document.formsAn array containing all the forms on the current page3
document.imagesAn array containing all the images on the current page27
document.linksAn array containing all the links on the current page81
document.anchorsAn array containing all the anchors on the current page0
document.appletsAn array containing all the applets on the current page2
document.styleSheetsAn array containing all the stylesheets on the current page4
window.framesAn array containing all the frames on the current page1

posted on 2006-12-06 10:30  javaca88  阅读(188)  评论(0)    收藏  举报