《电脑十万个为什么》

下载本书

添加书签

电脑十万个为什么- 第26部分


按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
  104;Q:用  javascript  操作  Cookie  示例
          A:
        //写  Cookie(用分号“;”把表达式“var=value”分隔开)
        function  Write2Cookie()
        {  document。cookie=〃v1=123;〃  +  〃path=/;〃;  
            document。cookie=〃v2=321;〃  +  〃path=/;〃;  
        }
        //读  Cookie
        function  getCookieVal(name)
        {
        var  firstCharPos;lastCharPos;
        var  theBigCookie  =  document。cookie;
        firstCharPos  =  theBigCookie。indexOf(name);
        if(firstCharPos  !=  …1)
        {//skip  'name'  and  '='。
        firstCharPos  +=name。length  +  1;
        //Find  the  end  of  the  value  string  (i。e。  the  next';')。
        lastCharPos  =  theBigCookie。indexOf(';';  firstCharPos);
        if(lastCharPos  ==  …1)  lastCharPos  =  theBigCookie。length;
        //Return  thevalue。
        return  theBigCookie。substring(firstCharPos;  lastCharPos);
        }
        else
        {  return  false;}
        }
        thev1=getCookieVal('v1')  //  read
        thev2=getCookieVal('v2')  //  read
  105;Q:电子邮件表单提交的问题
          A:首先必需正确配置邮件客户端(Outlook  Express  等)的帐户设置,这样,如果点按表单下的“提交”按钮,浏览器就会自动启用它发送邮件。目前,Foxmail  尚不支持这种电子邮件表单提交。    
  106;Q:用代码构造自己的窗口[小说下载网Jar电子书下载乐园—QiSuu。Com]
          A:
        function  xwindow(w;h;x;y;title;color;bordercolor;url)
        {
        move_function=〃var  isinit=false;r〃;
        move_function+=〃var  mywindowok=true;r〃;
        move_function+=〃function  mouseSTATUS()  {r〃;
        move_function+=〃this。x  =  null;r〃;
        move_function+=〃this。y  =  null;r〃;
        move_function+=〃this。bt  ='up';r〃;
        move_function+=〃this。oldx  =  null;r〃;
        move_function+=〃this。oldy  =  null;r〃;
        move_function+=〃this。dx  =  null;r〃;
        move_function+=〃this。dy  =  null;r〃;
        move_function+=〃this。screeny  =  null;r〃;
        move_function+=〃this。screenx  =  null;r〃;
        move_function+=〃this。element  =  null;r〃;
        move_function+=〃this。event  =  null;r〃;
        move_function+=〃}r〃;
        move_function+=〃var  mouse  =  new  mouseSTATUS();r〃;
        move_function+=〃function  actualizateMouseSTATUS(e)  {r〃;
        move_function+=〃if  (!e)  var  e  =  eventr〃;
        move_function+=〃if  ((e。type=='mousedown'  ||  e。type=='mouseup')  &&  e。button!=1)  return  truer〃;
        move_function+=〃var  x=e。x+document。body。scrollLeftr〃;
        move_function+=〃var  y=e。y+document。body。scrollTopr〃;
        move_function+=〃mouse。x=x;r〃;
        move_function+=〃mouse。y=y;r〃;
        move_function+=〃if  (e。type=='mousedown')  mouse。bt  =  'down';r〃;
        move_function+=〃else  if(e。type=='mouseup')  mouse。bt  =  'up';r〃;
        move_function+=〃if(window。event)  {r〃;
        move_function+=〃mouse。screenx=window。event。screenX;r〃;
        move_function+=〃mouse。screeny=window。event。screenY;r〃;
        move_function+=〃}  else  {r〃;
        move_function+=〃mouse。screenx=0;r〃;
        move_function+=〃mouse。screeny=0;r〃;
        move_function+=〃}}r〃;
        move_function+=〃function  initMouseEvents()  {r〃;
        move_function+=〃document。onmousedown  =  actualizateMouseSTATUSr〃;
        move_function+=〃document。onmousemove  =  actualizateMouseSTATUSr〃;
        move_function+=〃document。onmouseup  =  actualizateMouseSTATUSr〃;
        move_function+=〃document。onselectstart  =  selectstartr〃;
        move_function+=〃document。ondragstart  =  new  Function('actualizateMouseSTATUS(event);  return  false;')r〃;
        move_function+=〃}r〃;
        move_function+=〃function  selectstart(){r〃;
        move_function+=〃if  (  event。srcElement。tagName  !=  'INPUT'  &&  event。srcElement。tagName  !=  'TEXTAREA')  {  return  false;  }  r〃;
        move_function+=〃else  {  mouse。bt='up';  return  true;  }r〃;
        move_function+=〃}r〃;
        move_function+=〃initMouseEvents()r〃;
        move_function+=〃var  mywindowbt  ='up';r〃;
        move_function+=〃var  wincloseSTATUS='up';r〃;
        move_function+=〃var  ofx=0;r〃;
        move_function+=〃var  ofy=0;r〃;
        move_function+=〃var  opx=0;r〃;
        move_function+=〃var  opy=0;r〃;
        move_function+=〃var  px=0;r〃;
        move_function+=〃var  py=0;r〃;
        move_function+=〃var  wclosechanged  =  false;r〃;
        move_function+=〃function  initToMoveWin()  {r〃;
        move_function+=〃if(mouse。y  =  1  &&  mywindowbt  ==  'up'  &&  mouse。bt  =='up')  {  mywindowbt  =  'over'  }r〃;
        move_function+=〃  else  if  ((  mouse。y  》  22  ||  mouse。y  《  1  )  &&  mywindowbt  ==  'over'  &&  mouse。bt  =='up')  {  mywindowbt  =  'up'}r〃;
        move_function+=〃  else  if  (mouse。y  =1  &&  mywindowbt  ==  'over'  &&  mouse。bt  ==  'down'  )  {  r〃;
        move_function+=〃self。window。focus();r〃;
        move_function+=〃  ofx  =  mouse。x;r〃;
        move_function+=〃  ofy  =  mouse。y;r〃;
        move_function+=〃  opx  =  mouse。x;r〃;
        move_function+=〃  opy  =  mouse。y;r〃;
        move_function+=〃  mywindowbt='down';r〃;
        move_function+=〃}r〃;
        move_function+=〃  else  if  (  mouse。bt  =='up'  &&  mywindowbt  ==  'down'  )  {  〃;
        move_function+=〃  mywindowbt='up';〃;
        move_function+=〃  ofx=0;〃;
        move_function+=〃  ofy=0;〃;
        move_function+=〃  opx=0;  〃;
        move_function+=〃  opy=0;〃;
        move_function+=〃  }〃;
        move_function+=〃  else  if  (  mywindowbt  ==  'down'  &&  wincloseSTATUS  ==  'up')  {r〃;
        move_function+=〃  var  m_scrx  =  mouse。screenx;r〃;
        move_function+=〃  var  m_scry  =  mouse。screeny;r〃;
        move_function+=〃  px  =  m_scrx  …  ofx;r〃;
        move_function+=〃  py  =  m_scry  …  ofy;r〃;
        move_function+=〃  top。window。moveTo(px;py);r〃;
        move_function+=〃  }r〃;
        move_function+=〃  setTimeout('initToMoveWin()';1);r〃;
        move_function+=〃  }r〃;
        move_function+=〃  initToMoveWin()r〃;
        newWindow=window。open(〃〃;〃newWindow〃;〃fullscreen=1〃;〃width=〃+w+〃;height=〃+h);
        newWindow。resizeTo(w;h);
        newWindow。moveTo(x;y);
        newWindow。document。open();
        newWindow。document。write('');
        newWindow。document。write('r');
        newWindow。document。write('r');
        newWindow。document。write('r');
        newWindow。document。write('r');
        newWindow。document。write('');
        newWindow。document。write('');
        newWindow。document。close();
        newWindow。focus();
        }
        //……》
        

小提示:按 回车 [Enter] 键 返回书目,按 ← 键 返回上一页, 按 → 键 进入下一页。 赞一下 添加书签加入书架