随笔 - 147  文章 - 71  trackbacks - 0
<2009年2月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

常用链接

留言簿(1)

随笔分类(146)

随笔档案(147)

文章分类(28)

文章档案(28)

喜欢的Blog

搜索

  •  

最新评论

阅读排行榜

评论排行榜

改变浏览器状态栏文字提示
1<script language=”JavaScript”> 
2 window.status = “A new
 status message”; 
3
</script>

弹出确认提示框
1<script language=”JavaScript”> 
2 var userChoice =
 window.confirm(“Click OK or Cancel”); 
3 if (userChoice) 
{  
4
 document.write(“You chose OK”); 
5 }
 else {  
6
 document.write(“You chose Cancel”); 
7 }
 
8
</script>

提示输入
1<script language=”JavaScript”> 
2 var userName =
 window.prompt(“Please Enter Your Name”,”Enter Your Name Here”); 
3 document.write(“Your Name is “ +
 userName); 
4
</script>

打开一个新窗口
1<script language=”JavaScript”>
2 //打开一个名称为myNewWindow的浏览器新窗口 
3 window.open(“http://www.liu21st.com/”,”myNewWindow”); 
4
</script>

设置新窗口的大小
1<script language=”JavaScript”> 
2 window.open(“http://www.liu21st.com/”,”myNewWindow”,'height=300,width=300'); 

3
</script>

设置新窗口的位置
1<script language=”JavaScript”> 
2 window.open(“http://www.liu21st.com/”,”myNewWindow”,'height=300,width=300,left=200,screenX=200,top=100,screenY=100'); 

3
</script>

是否显示工具栏和滚动栏
1<SCRIPT LANGUAGE="javascript"> 
2 window.open("http://www.liu21st.com/","newwindow","height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no"

3
</SCRIPT> 

是否可以缩放新窗口的大小
1<script language=”JavaScript”> 
2 window.open("http://www.liu21st.com/" , "myNewWindow""resizable=yes"
);
3
</script>

加载一个新的文档到当前窗口
1<href='#' onClick='document.location = '125a.html';' >Open New Document</a>

设置页面的滚动位置
1<script language=”JavaScript”> 
2 if (document.all) 
//如果是IE浏览器则使用scrollTop属性 
3 document.body.scrollTop = 200
4 }
 else //如果是NetScape浏览器则使用pageYOffset属性 
5 window.pageYOffset = 200
6 }

7
</script>

在IE中打开全屏窗口
1<href='#' onClick=”window.open('http://www.juxta.com/','newWindow','fullScreen=yes');”>Open a full-screen window</a>

新窗口和父窗口的操作
1<script language=”JavaScript”> 
2 //定义新窗口 

3 var newWindow = window.open(“128a.html”,”newWindow”); 
4 newWindow.close(); //在父窗口中关闭打开的新窗口 

5
</script> 
6
在新窗口中关闭父窗口 
7window.opener.close();

往新窗口中写内容
1<script language=”JavaScript”> 
2 var newWindow =
 window.open(“”,”newWindow”); 
3
 newWindow.document.open(); 
4 newWindow.document.write(“This is a new
 window”); 
5
 newWIndow.document.close(); 
6
</script>

加载页面到框架页面
1<frameset cols=”50%,*”> 
2 <frame name=”frame1” src="/”135a.html">
 
3 <frame name=”frame2” src="/”about:blank">
 
4</frameset>
 
5
在frame1中加载frame2中的页面 
6parent.frame2.document.location = “135b.html”;

在框架页面之间共享脚本
如果在frame1中html文件中有个脚本
1function doAlert() {  
2 window.alert(“Frame 1 is loaded”); 
3}
那么在frame2中可以如此调用该方法
1<body onLoad=”parent.frame1.doAlert();”> 
2 This is frame 2. 
3</body>

数据公用
可以在框架页面定义数据项,使得该数据可以被多个框架中的页面公用
1<script language=”JavaScript”> 
2 var persistentVariable = “This is a persistent value”; 
3
</script> 
4<frameset cols=”50%,*”> 
5 <frame name=”frame1” src="/”138a.html"> 
6 <frame name=”frame2” src="/”138b.html"> 
7</frameset>
这样在frame1和frame2中都可以使用变量persistentVariable
框架代码库
1<frameset cols=”0,50%,*”> 
2 <frame name=”codeFrame” src="/”140code.html"> 
3 <frame name=”frame1” src="/”140a.html"> 
4 <frame name=”frame2” src="/”140b.html"> 
5</frameset>
posted on 2009-02-11 10:49 飞翔天使 阅读(561) 评论(0)  编辑  收藏 所属分类: javascript

只有注册用户登录后才能发表评论。


网站导航: