zoukankan      html  css  js  c++  java
  • javascript 基本用法简结

    一、Windows操作对象

         1、窗口操作:

              moveBy(dx,dy)把浏览器窗口相对位置水平移动dx像素,垂直移动dy个像素。dx为负数 向左移动,dy为负向上移动

              moveTo(x,y)移动到位于左上角跑那个木的x,y处(负数)

              resizeBy(dw,dh)扩大当前窗口的宽+dw 个像素 高+dh个像素 (负数)

              resizeTo(w,h)把宽高调整到w,h (不能使用负数)

         2、导航和打开新窗口:

              windows.open("http://www.baidu.com/","载入的框架ID")

              windows.open("地址","wroxwindow","height=150,width=300,top=10,left=10,resizable=yes") 第三个参数定义新窗口属性。

              var newWin=window.open()

              newWin.moveTo()

         3、系统对话框

              1.alert()用与输入数据无效时

              2.confirm() 显示 OK Cancel按钮

              if(confirm("Are you sure?")){

              alert("sure");

              }else{

                        alert("not sure");

              }

              3.prompt()显示给用户输入的对话框

               var Result= prompt("What's your name ?","Michael";)

              if(result!=null){}

              4、状态栏。

                   window.defaultStatus="dddd";

                   当鼠标移动到某个连接上时显示该连接的信息:

                   <a href="xx.html" onmouseover="window.status='information on wros books.' ">book</a>

              5、时间间隔和暂停window对象的setTimeout方法

                   setTimeout(执行的代码, 暂停的毫秒数)

                   var time= serTimeout(function(){alert();},1000);

                   clearTimeout(time);

                   setInterval("代码",1000)代码每次执行之间等待的毫秒数

              6、历史   go()前进或后退的页面数

                   window.history.go(-1) 后退一页

                        <a href="javascript:history.go(-1)">back</a> 

                   history.back();  history.forward()可以实现同样的操作。

              7、location

                   location.href="网址";

                   location.reload(true);从服务器端重载当前页面

                   location.reload(false);或者location.reload();从缓存重载当前页面

                   location.toString()返回location.href的值。

              8、screen对象

                   screen.availHeight 窗口可以使用的屏幕的高度像素

                   screen.availWidth 窗口可以使用的屏幕的宽度像素

                   heigth、with屏幕的高度、宽度

  • 相关阅读:
    java编译错误No enclosing instance of type TestFrame is accessible. Must qualify the allocation with an enclosing instance of type TestFrame (e.g. x.new A(
    java 2中创建线程方法
    动态规划基本思想
    关于eclipse编译一个工程多个main函数
    java Gui初识
    Eclipse中java项目的打包
    java 播放声音
    把资源文件夹导入到eclipse中
    Java建立JProgressBar
    How to grant permissions to a custom assembly that is referenced in a report in Reporting Services
  • 原文地址:https://www.cnblogs.com/hyd309/p/1335187.html
Copyright © 2011-2022 走看看