| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1746 人关注过本帖
标题:[求助]window.event 是什么对象啊?
只看楼主 加入收藏
84056686
Rank: 1
等 级:新手上路
帖 子:71
专家分:0
注 册:2005-10-11
收藏
 问题点数:0 回复次数:4 
[求助]window.event 是什么对象啊?
1.window.event是什么啊,很多javescript里面都可以直接调用他的属性.
2.他倒底还有哪些属性?
3.类似于event的对象还有哪些?
4.有没有相关的可以查找的资料什么呢?
搜索更多相关主题的帖子: event window 对象 属性 
2005-11-28 10:08
conn
Rank: 2
等 级:新手上路
威 望:5
帖 子:420
专家分:0
注 册:2005-11-27
收藏
得分:0 
偶是新手,给不了你什么解答,偶给你顶一下,期待中....

我是新手,但我很虚心,对我发的问题请不要取笑,谢谢
2005-11-28 11:18
conn
Rank: 2
等 级:新手上路
威 望:5
帖 子:420
专家分:0
注 册:2005-11-27
收藏
得分:0 
event 代表事件状态,如事件发生的元素,键盘状态,鼠标位置和鼠标按钮状态。

呵呵,哥们看看我发的帖子,不过给你的答案就这点,具体的只有你自己去网上找喽,呵呵~

我是新手,但我很虚心,对我发的问题请不要取笑,谢谢
2005-11-28 11:25
84056686
Rank: 1
等 级:新手上路
帖 子:71
专家分:0
注 册:2005-10-11
收藏
得分:0 

谢谢。

我去网上找找。


吃不到葡萄说葡萄酸。 吃到了葡萄知道葡萄真是很酸! ——(wolf)
2005-11-28 11:27
linuxpluto
Rank: 4
等 级:贵宾
威 望:13
帖 子:889
专家分:23
注 册:2005-8-14
收藏
得分:0 
事件 事件句柄 事件发生的条件……
abort onAbort The user aborts the loading of an image (for example by clicking a link or clicking the Stop button).
blur onBlur A form element loses focus or when a window or frame loses focus.
change onChange A select, text, or textarea field loses focus and its value has been modified.
click onClick An object on a form is clicked.
dblclick onDblClick The user double-clicks a form element or a link.
dragdrop onDragDrop The user drops an object onto the browser window, such as dropping a file on the browser window.
error onError The loading of a document or image causes an error.
focus onFocus A window, frame, or frameset receives focus or when a form element receives input focus.
keydown onKeyDown The user depresses a key.
keypress onKeyPress The user presses or holds down a key.
keyup onKeyUp The user releases a key.
load onLoad The browser finishes loading a window or all of the frames within a FRAMESET tag.
mousedown onMouseDown The user depresses a mouse button.
mousemove onMouseMove The user moves the cursor.
mouseout onMouseOut The cursor leaves an area (client-side image map) or link from inside that area or link.
mouseover onMouseOver The cursor moves over an object or area from outside that object or area.
mouseup onMouseUp The user releases a mouse button.
move onMove The user or script moves a window or frame.
reset onReset The user resets a form (clicks a Reset button).
resize onResize The user or script resizes a window or frame.
select onSelect The user selects some of the text within a text or textarea field.
submit onSubmit The user submits a form.
unload onUnload The user exits a document.

General Information about Events

JavaScript applications in the browser are largely event-driven. Events are actions that occur usually as a result of something the user does. For example, clicking a button is an event, as is changing a text field or moving the mouse over a link. For your script to react to an event, you define event handlers, such as onChangeandonClick.

定义事件句柄

If an event applies to an HTML tag, then you can define an事件适用对象it. The name of an event handler is the name of the event, preceded by "on". For example, the事件适用对象the focus event is onFocus.

To create an事件适用对象an HTML tag, add an event handler attribute to the tag. Put JavaScript code in quotation marks as the attribute value. The general语法 is

<TAG eventHandler="JavaScript Code"> where TAG is an HTML tag and eventHandler is the name of the event handler. For example, suppose you have created a JavaScript function called compute. You can cause the browser to perform this function when the user clicks a button by assigning the function call to the button's onClick event handler:

<INPUT TYPE="button" VALUE="Calculate" onClick="compute(this.form)"> You can put any JavaScript statements inside the quotation marks following onClick. These statements are executed when the user clicks the button. If you want to include more than one statement, separate statements with a semicolon.

When you create an event handler, the corresponding JavaScript object gets a property with the name of the event handler in lower case letters. (In Navigator 4.0, you can also use the mixed case name of the事件适用对象the property name.) This property allows you to access the object's event handler. For example, in the preceding example, JavaScript creates a Button object with an onclick property whose value is "compute(this.form)".

Chapter 7, "JavaScript Security," in JavaScript Guide contains more information about creating and using event handlers.

Events in Navigator 4.0

In Navigator 4.0, JavaScript includes event objects as well as event handlers. Each event has an event object associated with it. The event object provides information about the event, such as the type of event and the location of the cursor at the time of the event. When an event occurs, and if an event handler has been written to handle the event, the event object is sent as an argument to the event handler.

Typically, the object on which the event occurs handles the event. For example, when the user clicks a button, it is often the button's event handler that handles the event. Sometimes you may want the Window or document object to handle certain types of events. For example, you may want the document object to handle all MouseDown events no matter where they occur in the document. JavaScript's event capturing model allows you to define methods that capture and handle events before they reach their intended target.

In addition to providing the event object, Navigator 4.0 allows a Window or document to capture and handle an event before it reaches its intended target. To accomplish this, the Window, document, and Layer objects have these new methods:

For example, suppose you want to capture all click events that occur in a window. First, you need to set up the window to capture click events:

window.captureEvents(Event.CLICK); The argument to Window.captureEvents is a property of the event object and indicates the type of event to capture. To capture multiple events, the argument is a list separated by vertical slashes (|). For example:

window.captureEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP) Next, you need to define a function that handles the event. The argument evnt is the event object for the event.

function clickHandler(evnt) {
//What goes here depends on how you want to handle the event.
//This is described below.
}
You have four options for handling the event:

Finally, you need to register the function as the window's事件适用对象that event:

window.onClick = clickHandler;

注意

If a window with frames wants to capture events in pages loaded from different locations, you need to use captureEvents in a signed script and call Window.enableExternalCapture. In the following example, the window and document capture and release events:

<HTML>
<SCRIPT>
function fun1(evnt) {
alert ("The window got an event of type: " + evnt.type +
" and will call routeEvent.");
window.routeEvent(evnt);
alert ("The window returned from routeEvent.");
return true;
}
function fun2(evnt) {
alert ("The document got an event of type: " + evnt.type);
return false;
}
function setWindowCapture() {
window.captureEvents(Event.CLICK);
}
function releaseWindowCapture() {
window.releaseEvents(Event.CLICK);
}
function setDocCapture() {
document.captureEvents(Event.CLICK);
}
function releaseDocCapture() {
document.releaseEvents(Event.CLICK);
}
window.onclick=fun1;
document.onclick=fun2;
</SCRIPT>
...
</HTML>


吃的比猪还差,干的比驴还累,起的比鸡还早,睡得比小姐还晚,挣得比民工还少,看起来比谁都好——苦命的人.人生短短几十年,不要给自己留下了什么遗憾,想笑就笑,想哭就哭,该爱的时候就去爱,无谓压抑自己
2005-11-29 08:33
快速回复:[求助]window.event 是什么对象啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016686 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved