免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1459 | 回复: 0
打印 上一主题 下一主题

JavaScript就这么回事5:窗口和框架 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-10 00:14 |只看该作者 |倒序浏览
54 改变浏览器状态栏文字提示
  • script language=”JavaScript”>
  • window.status = “A new status message”;

  • 55 弹出确认提示框
  • script language=”JavaScript”>
  • var userChoice = window.confirm(“Click OK or Cancel”);
  • if (userChoice) {
  • document.write(“You chose OK”);
  • } else {
  • document.write(“You chose Cancel”);
  • }

  • 56 提示输入
  • script language=”JavaScript”>
  • var userName = window.prompt(“Please Enter Your Name”,”Enter Your Name Here”);
  • document.write(“Your Name is “ + userName);

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

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

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

  • 60 是否显示工具栏和滚动栏
  • script language=”JavaScript”>
  • window.open(“http:
    61 是否可以缩放新窗口的大小
  • script language=”JavaScript”>
  • window.open('http://www.liu21st.com/' , 'myNewWindow', 'resizable=yes' );
    62 加载一个新的文档到当前窗口
  • a href='#' onClick='document.location = '125a.html';' >Open New Documenta>
    63 设置页面的滚动位置
  • script language=”JavaScript”>
  • if (document.all) { //如果是IE浏览器则使用scrollTop属性
  • document.body.scrollTop = 200;
  • } else { //如果是NetScape浏览器则使用pageYOffset属性
  • window.pageYOffset = 200;
  • }
    64 在IE中打开全屏窗口
  • a href='#'  onClick=”window.open('http://www.juxta.com/','newWindow','fullScreen=yes');”>Open a full-screen windowa>
    65 新窗口和父窗口的操作
  • script language=”JavaScript”>
  • //定义新窗口
  • var newWindow = window.open(“128a.html”,”newWindow”);
  • newWindow.close(); //在父窗口中关闭打开的新窗口

  • 在新窗口中关闭父窗口
  • window.opener.close()
    66 往新窗口中写内容
  • script language=”JavaScript”>
  • var newWindow = window.open(“”,”newWindow”);
  • newWindow.document.open();
  • newWindow.document.write(“This is a new window”);
  • newWIndow.document.close();

  • 67 加载页面到框架页面
  • frameset cols=”50%,*”>
  • frame name=”frame1” src=”135a.html”>
  • frame name=”frame2” src=”about:blank”>
  • frameset>
  • 在frame1中加载frame2中的页面
  • parent.frame2.document.location = “135b.html”;
    68 在框架页面之间共享脚本
    如果在frame1中html文件中有个脚本
  • function doAlert() {
  • window.alert(“Frame 1 is loaded”);
  • }
    那么在frame2中可以如此调用该方法
  • body onLoad=”parent.frame1.doAlert();”>
  • This is frame 2.
  • body>
    69 数据公用
    可以在框架页面定义数据项,使得该数据可以被多个框架中的页面公用
  • script language=”JavaScript”>
  • var persistentVariable = “This is a persistent value”;





  • 这样在frame1和frame2中都可以使用变量persistentVariable
    70 框架代码库
    根据以上的一些思路,我们可以使用一个隐藏的框架页面来作为整个框架集的代码库
  • frameset cols=”0,50%,*”>
  • frame name=”codeFrame” src=”140code.html”>
  • frame name=”frame1” src=”140a.html”>
  • frame name=”frame2” src=”140b.html”>
  • frameset>

    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/15511/showart_97515.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP