onreadystatechange对象发生改变时激发
2008-02-29 13:34
232 查看
Fires when the state of the object has changed.
当对象发生改变时激发。
Syntax
语法
Inline HTML <ELEMENT onreadystatechange = "handler" ... > All platforms
Event property object.onreadystatechange = handler JScript only
object.onreadystatechange = GetRef("handler") Visual Basic Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = object EVENT = onreadystatechange> Internet Explorer only
Event Information
Bubbles No
Cancels No
To invoke Change the ready state.
Default action Signals the ready state of the document.
Event Object Properties
Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.
Show Available Properties
altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
shiftLeft Retrieves the state of the left SHIFT key.
srcElement Sets or retrieves the object that fired the event.
type Sets or retrieves the event name from the event object.
Remarks
You can use the readyState property to query the current state of the element when the onreadystatechange event fires.
All elements expose an onreadystatechange event. The following objects always fire the event because they load data: applet, document, frame, frameSet, iframe, img, link, object, script, and xml elements. Other objects will only fire the onreadystatechange event when a DHTML Behavior is attached.
When working with behaviors, wait for the onreadystatechange event to fire and verify that the readyState property of the element is set to complete to ensure that the behavior is completely downloaded and applied to the element. Until the onreadystatechange event fires, if you use any of the behavior-defined members before attaching the behavior to the element, a scripting error can result, indicating that the object does not support that particular property or method.
Example
This example uses the onreadystatechange event to invoke a function when the readyState is complete.
HideExample
document.onreadystatechange=fnStartInit;
function fnStartInit()
{
if (document.readyState=="complete")
{
// Finish initialization.
}
}
Internet Explorer only
Event Information
Bubbles No
Cancels No
To invoke Change the ready state.
Default action Signals the ready state of the document.
Event Object Properties
Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.
Show Available Properties
altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
shiftLeft Retrieves the state of the left SHIFT key.
srcElement Sets or retrieves the object that fired the event.
type Sets or retrieves the event name from the event object.
Remarks
You can use the readyState property to query the current state of the element when the onreadystatechange event fires.
All elements expose an onreadystatechange event. The following objects always fire the event because they load data: applet, document, frame, frameSet, iframe, img, link, object, script, and xml elements. Other objects will only fire the onreadystatechange event when a DHTML Behavior is attached.
When working with behaviors, wait for the onreadystatechange event to fire and verify that the readyState property of the element is set to complete to ensure that the behavior is completely downloaded and applied to the element. Until the onreadystatechange event fires, if you use any of the behavior-defined members before attaching the behavior to the element, a scripting error can result, indicating that the object does not support that particular property or method.
Example
This example uses the onreadystatechange event to invoke a function when the readyState is complete.
HideExample
document.onreadystatechange=fnStartInit;
function fnStartInit()
{
if (document.readyState=="complete")
{
// Finish initialization.
}
}
<script>
var img=null;
function s()
{
if(img)
img.removeNode(true);
img=document.createElement("img");
img.style.position="absolute";
img.style.visibility="hidden";
img.attachEvent("onreadystatechange",orsc);
img.attachEvent("onerror",oe);
document.body.insertAdjacentElement("beforeend",img);
img.src=inp.value;
}
function oe()
{
alert("cant load img");
}
function orsc()
{
if(img.readyState!="complete")return false;
alert("高:"+img.offsetHeight+"/n宽:"+img.offsetWidth);
}
</script>
<input type="file" Name="file" id="inp" value="默认值"><br>
<input onclick="s()" type="button" value="点我一下给出要上传图片的大小及长、宽" name="button">
当对象发生改变时激发。
Syntax
语法
Inline HTML <ELEMENT onreadystatechange = "handler" ... > All platforms
Event property object.onreadystatechange = handler JScript only
object.onreadystatechange = GetRef("handler") Visual Basic Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = object EVENT = onreadystatechange> Internet Explorer only
Event Information
Bubbles No
Cancels No
To invoke Change the ready state.
Default action Signals the ready state of the document.
Event Object Properties
Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.
Show Available Properties
altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
shiftLeft Retrieves the state of the left SHIFT key.
srcElement Sets or retrieves the object that fired the event.
type Sets or retrieves the event name from the event object.
Remarks
You can use the readyState property to query the current state of the element when the onreadystatechange event fires.
All elements expose an onreadystatechange event. The following objects always fire the event because they load data: applet, document, frame, frameSet, iframe, img, link, object, script, and xml elements. Other objects will only fire the onreadystatechange event when a DHTML Behavior is attached.
When working with behaviors, wait for the onreadystatechange event to fire and verify that the readyState property of the element is set to complete to ensure that the behavior is completely downloaded and applied to the element. Until the onreadystatechange event fires, if you use any of the behavior-defined members before attaching the behavior to the element, a scripting error can result, indicating that the object does not support that particular property or method.
Example
This example uses the onreadystatechange event to invoke a function when the readyState is complete.
HideExample
document.onreadystatechange=fnStartInit;
function fnStartInit()
{
if (document.readyState=="complete")
{
// Finish initialization.
}
}
Internet Explorer only
Event Information
Bubbles No
Cancels No
To invoke Change the ready state.
Default action Signals the ready state of the document.
Event Object Properties
Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.
Show Available Properties
altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
shiftLeft Retrieves the state of the left SHIFT key.
srcElement Sets or retrieves the object that fired the event.
type Sets or retrieves the event name from the event object.
Remarks
You can use the readyState property to query the current state of the element when the onreadystatechange event fires.
All elements expose an onreadystatechange event. The following objects always fire the event because they load data: applet, document, frame, frameSet, iframe, img, link, object, script, and xml elements. Other objects will only fire the onreadystatechange event when a DHTML Behavior is attached.
When working with behaviors, wait for the onreadystatechange event to fire and verify that the readyState property of the element is set to complete to ensure that the behavior is completely downloaded and applied to the element. Until the onreadystatechange event fires, if you use any of the behavior-defined members before attaching the behavior to the element, a scripting error can result, indicating that the object does not support that particular property or method.
Example
This example uses the onreadystatechange event to invoke a function when the readyState is complete.
HideExample
document.onreadystatechange=fnStartInit;
function fnStartInit()
{
if (document.readyState=="complete")
{
// Finish initialization.
}
}
<script>
var img=null;
function s()
{
if(img)
img.removeNode(true);
img=document.createElement("img");
img.style.position="absolute";
img.style.visibility="hidden";
img.attachEvent("onreadystatechange",orsc);
img.attachEvent("onerror",oe);
document.body.insertAdjacentElement("beforeend",img);
img.src=inp.value;
}
function oe()
{
alert("cant load img");
}
function orsc()
{
if(img.readyState!="complete")return false;
alert("高:"+img.offsetHeight+"/n宽:"+img.offsetWidth);
}
</script>
<input type="file" Name="file" id="inp" value="默认值"><br>
<input onclick="s()" type="button" value="点我一下给出要上传图片的大小及长、宽" name="button">
相关文章推荐
- docement.onreadystatechange页面加载状态
- onreadyStateChange在Firefox中存在的差异
- 对onreadystatechange属性的理解
- window.onload,body onload,document.onreadystatechange
- script.onload=script.onreadystatechange=function()的作用
- <script>标签的onload和onreadystatechange事件以及defer属性
- AJAX - onreadystatechange 事件
- Use the onReadyStateChange Property (Visual Basic)
- 使用 document.onreadystatechange()来判断页面加载完
- ajax 的 onreadystatechange 事件为何触发多次
- 关于onreadystatechange属性的一点疑问
- 仅IE9/10同时支持script元素的onload和onreadystatechange事件分析
- Change Reference to Value(将引用对象改变为实值对象)
- Html之Frame的onreadystatechange 事件-yellowcong
- Observer 在对象之间定义一个一对多的依赖关系,从而当一个对象状态发生改变时,所有依赖于这个对象的对象都能够得到通知,并对上述改变做出反应.
- Ajax onreadystatechange
- document.onreadystatechange的认识
- window.onload,<body onload="function()">, document.onreadystatechange, httpRequest.onreadystatechang
- FindFirstChangeNotification,创建一个文件通知对象,该对象用于监视文件系统发生的变化