search

js心得2

Jun 07, 2016 pm 03:43 PM
namewholeExperiencetextform

1.表单中的文本框完整的名称应该是: window.document.myform.text1,其中window可以省略,所以我们前面写为: document.myform.text1就是这样来的。 1)window窗口对象是代表整个浏览器窗口,是最顶层的根。 2)往下包括history历史对象(存放历史信息,可

1.表单中的文本框完整的名称应该是:

window.document.myform.text1,其中window可以省略,所以我们前面写为:

document.myform.text1就是这样来的。

1)window窗口对象是代表整个浏览器窗口,是最顶层的根。

2)往下包括history历史对象(存放历史信息,可以前进后退的功能)、

 

2.Window 对象:

名称

说明

document

表示给定浏览器窗口中的 HTML 文档。

history 

包含有关客户访问过的URL的信息。

location

包含有关当前 URL 的信息。

name

设置或检索窗口或框架的名称。

status 

设置或检索窗口底部的状态栏中的消息。

screen

包含有关客户端的屏幕和显示性能的信息。

 

  

方法

名称

说明

alert  (“m提示信息")

显示包含消息的对话框。

confirm(“提示信息”)

显示一个确认对话框,包含一个确定取消按钮

prompt(”提示信息“)

弹出提示信息框

open  ("url","name")

打开具有指定名称的新窗口,并加载给定 URL 所指定的文档;如果没有提供 URL,则打开一个空白文档

close  ( )

关闭当前窗口

setTimeout(”函数”,毫秒数)

设置定时器:经过指定毫秒值后执行某个函数

clearTimeout(定时器对象)

取消setTimeout设置

confirm弹出确认对话框,点击确定返回true ,取消返回false

3.open(”打开窗口的url”,”窗口名”,”窗口特征”)

 

窗口的特征如下,可以任意组合:

height: 窗口高度;

width: 窗口宽度;

top: 窗口距离屏幕上方的象素值;

left:窗口距离屏幕左侧的象素值;

toolbar: 是否显示工具栏,yes为显示;

menubar,scrollbars 表示菜单栏和滚动栏。

resizable: 是否允许改变窗口大小,yes或1为允许

location: 是否显示地址栏,yes或1为允许

status:是否显示状态栏内的信息,yes或1为允许;

4.全屏显示窗口:

screen.availWidth---屏幕的宽度 (除 Windows 任务栏之外)

screen.availHeight---屏幕的高度 (除 Windows 任务栏之外)。

例如:

也可用:screen.width---显示器屏幕的宽度

              screen.height---显示屏幕的高度 

?        5.window对象提供了两种方法来实现定时器:

–      window. setTimeout(表达式[expression],延时时间[n]),每N秒执行一次

–      window. setInterval(表达式[expression],延时时间[n]),过N秒执行一次,循环!

注意:expression可以是用引号括起来的代码,也可以是一个函数名(不能带任何参数的函数):

setTimeout("move()",1000);或setTimeout(move,1000);

?        如何取消定时器:

–      取消setTimeout:window.clearTimeout(id);

–      取消setInterval:window.clearInterval(id);

6.屏幕(screen)对象

?        屏幕对象是JavaScript运行时自动产生的对象

?        屏幕对象常用属性

–      height:返回显示屏幕的高度。

–      width :返回显示器屏幕的宽度。

–      availHeight :返回显示屏幕的高度 (除 Windows 任务栏之外)。

–      availWidth:返回显示屏幕的宽度 (除 Windows 任务栏之外)。

–      colorDepth:返回目标设备或缓冲器上的调色板的比特深度(每像素中用于颜色的位数,其值为1,4,8,15,16,24,32)。

?        网页可见区域宽:document.body.clientWidth

?        网页可见区域高:document.body.clientHeight

?        网页可见区域宽:document.body.offsetWidth (包括边线的宽)

?        网页可见区域高:document.body.offsetHeight (包括边线的宽)

?        网页正文全文宽:document.body.scrollWidth

?        网页正文全文高:document.body.scrollHeight

?        网页被卷去的高:document.body.scrollTop

?        网页被卷去的左:document.body.scrollLeft

?        网页正文部分上:window.screenTop

?        网页正文部分左:window.screenLeft

?        屏幕分辨率的高:window.screen.height

?        屏幕分辨率的宽:window.screen.width

?        屏幕可用工作区高度:window.screen.availHeight

?        屏幕可用工作区宽度:window.screen.availWidth

?        处理地址栏信息:location对象

–      Location对象是wodow对象的子对象,包含了窗口对象的网页地址内容,即URL。例如:

?        window.location=“http://www.sohu.com”;//跳转到页面

?        window.loaction.href=“http://www.sohu.com”;//同上

?        window.location.reload();//刷新页面

?        Window.location.replace(url);//用url刷新当前网页

–      用三种方法改变当前网页的网站:

方法1:window.open()   

方法2:
 location.href   

方法3: location.replace()

7.Location对象属性

名称

说明

host

设置或检索位置或 URL 的主机名和端口号

hostname

设置或检索位置或 URL 的主机名部分

Href

设置或检索完整的 URL 字符串

方法:

名称

说明

assign("url")

加载 URL 指定的新的 HTML 文档。 

reload()

重新加载当前页

replace("url")

通过加载 URL 指定的文档来替换当前文档

8.历史记录(history)对象

?        历史记录对象是窗口对象下的一个子对象。它实际上是一个对象数组,包含了一系列的用户访问过的url地址,用于浏览器工具栏中的“前进”和“后退”按钮。

?        常用属性和方法

–      history.length:历史对象的个数

–      history.back();显示浏览器历史列表中后退一个网址的网页

–      history.go(n)或者history.go(网址):显示浏览器的历史列表中第n个网址的网页,n>0 前进  n

–      history.forward();//显示浏览器历史列表中前进一个网址的网页

9.Document对象

?        document文档对象是window对象的一个主要部分,它包含了网页显示的各个元素对象。

–      document.write(str);//输出一行

–      document.writeln(str);//输出一行,并回车

属性:

名称

说明

alinkColor

设置或检索文档中所有活动链接的颜色

bgColor

设置或检索 Document 对象的背景色

body

指定文档正文的开始和结束

linkColor

设置或检索文档链接的颜色

location

包含关于当前 URL 的信息

title

包含文档的标题

url

设置或检索当前文档的 URL

vlinkColor

设置或检索用户访问过的链接的颜色

常用方法:

名称

说明

clear ( )

清除当前文档

close ( )

关闭输出流并强制显示发送的数据

write ("text")

将文本写入文档

本节重点:

?        JavaScript 程序是事件驱动程序

?        onFocus获得焦点事件,表示获得鼠标光标, onBlur失去焦点事件,刚好与之相反

?        浏览器对象是一个分层次的结构,window是顶层根对象

?        打开窗口使用window对象的open( )方法

?        设置定时器,使用window对象的setTimeout( )方法

?        location对象的back( )和forward( )方法等同于前进、后退按钮

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are stored procedures in MySQL?What are stored procedures in MySQL?May 01, 2025 am 12:27 AM

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

How does query caching work in MySQL?How does query caching work in MySQL?May 01, 2025 am 12:26 AM

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

What are the advantages of using MySQL over other relational databases?What are the advantages of using MySQL over other relational databases?May 01, 2025 am 12:18 AM

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment