onreadystatechange
状態が変化した時に発生するイベントです。
構文
オブジェクト.onreadystatechange = "イベント発生時の処理"
例文
<html> <head> <title>onreadystatechange</title> <script type="text/javascript"><!-- function loadTextFile() { httpObj = createXMLHttpRequest(displayData); if (httpObj) { httpObj.open("get","data.txt",true); httpObj.send(null); } } function displayData() { if ((httpObj.readyState == 4) && (httpObj.status == 200)) { document.getElementById("result").value = httpObj.responseText; } } // HTTP通信用、共通関数 function createXMLHttpRequest(cbFunc) { var XMLhttpObject = null; try{ XMLhttpObject = new XMLHttpRequest(); }catch(e){ try{ XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ return null; } } } if (XMLhttpObject) XMLhttpObject.onreadystatechange = cbFunc; return XMLhttpObject; } // --></script> </head> <body> <h1>onReadyState Change</h1> <form name="ajaxForm"> <input type="button" value="読み込み" onClick="loadTextFile()"><br> <textarea name="result" cols="40" rows="5" id="result"></textarea> </form> </body> </html>
関連記事
- DOMMouseScroll
- onUnload
- onSubmit
- onStop
- onStart
- onSelectStart
- onSelectionChange
- onSelect
- onScroll
- onResizeStart
- onResizeEnd
- onResize
- onReset
- onPaste
- onMoveStart
- onMoveEnd
- onMove
- onMouseWheel
- onMouseUp
- onMouseOver
- onMouseOut
- onMouseMove
- onMouseLeave
- onMouseEnter
- onMouseDown
- onLoad
- onKeyUp
- onKeyPress
- onKeyDown
- onHelp
- onFocusOut
- onFocusIn
- onFocus
- onFinish
- onError
- onDragStart
- onDragOver
- onDragLeave
- onDragEnter
- onDragEnd
- onDrag
- onDblClick
- onCut
- onCopy
- onContextMenu
- onClick
- onChange
- onBlur
- onBeforeUnload
- onBeforePrint
- onBeforePaste
- onBeforeCut
- onBeforeCopy
- onAfterPrint
- onAbort
- event.y
- event.x
- event.wheelDelta
- event.type
- event.toElement
- event.screenY
- event.screenX
- event.keyCode
- event.pageY
- event.pageX
- event.offsetY
- event.offsetX
- event.srcElement
- event.detail
- event.clientY
- event.clientX
スポンサーリンク