Javascript monitoring input _ _ jump to read and display file

 

<! - after the pop-up dialog box to enter the character input -> 
< head > 
    < Script of the type = "text / JavaScript" > 
    // Firefox, Google Chrome, Opera, Safari, Internet Explorer from Version 9 
        function onInput (Event) { 
            Alert (event.target.value); 
        } 
    // the Internet Explorer 
        function OnPropChanged (Event) {
             IF (event.propertyName.toLowerCase () ==  " value " ) { 
                Alert (event.srcElement.value); 
            } 
        } 
    </ Script >
</head>
<body>
    <input type="text" oninput="OnInput (event)" onpropertychange="OnPropChanged (event)" value="input something" /><br>
</body>

<!--根据按键跳转到网页-->
<script type="text/javascript">
    function enterHandler()
    {
        var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
        IF (the keyCode ==  65 ) 
        { 
            window.location.href = ' http://www.baidu.com ' ; 
        } 
    } 
</ Script > 
< body onKeyDown = "enterHandler ()" > 
    < A the href = HTTPS: // www.runoob.com/tags/html-ascii.html > the ASCII characters corresponding to the sequence number </ A > , such as: A corresponds to 65, press the button A, the jump page. <br>
 </ body > 

<-! online to read the file contents -> 
<! DOCTYPE HTML > 
<
    <head>
        <title>文件示例</title>
        <meta name="name" content="content" charset="gb2312">
    </head>
    <body>
            <input type="file" id="file" />
            <input type="button" onclick="readText()" value="File Button">
            <div id="tt">
            </div>
    </body > 
</ HTML > 
< Script charset = "UTF-. 8" > 
the window.onload = function () {
     IF ( typeof (the FileReader) == " undefined " ) 
    { 
        Alert ( " Your browser does not support file read " ); 
        document.write ( "" ); 
    } the else 
    { 
        Alert ( " your browser supports file read " ); 
    } 
} 
    function readText () {
             var file=document.getElementById("file").files[0];
            var reader=new FileReader();
            reader.readAsText(file);
            reader.onload=function(data)
            {
                var tt=document.getElementById("tt")
                tt.innerHTML=this.result;
            }
        }
    
</script>

 

Guess you like

Origin www.cnblogs.com/chenxiehan/p/12585159.html