zoukankan      html  css  js  c++  java
  • js高级编程笔记2

    1.document.open -- 打开已经载入的文档
    var win = window.open("about:blank","dreamdu");
    win.document.open();
    win.document.write("welcome to dreamdu!");
    win.document.close();
    2.document.getSelection()获取页面上选中的文字:
    <script type="text/javascript">
    var isNav = (navigator.appName.indexOf("Netscape") !=-1);
    function showSelection(){
    if(window.getSelection) {
    alert(window.getSelection());
    }
    else if (document.getSelection) {
    alert(document.getSelection());

    }
    else if (document.selection) {
    alert(document.selection.createRange().text);
    }
    }
    if (isNav) {
    document.captureEvents(Event.MOUSEUP);
    }
    document.onmouseup = showSelection;
    </script>
    </head>
    <body>aaaaaaaaaaaaaaaa1111111111111
    <textarea name="selectedText" rows = 3 cols=40 wrap="virtusl">
    </textarea>
    </body>

    ff中:

    function getTextFieldSelection(e) {
    if (e.selectionStart != undefined && e.selectionEnd != undefined) {
    var start = e.selectionStart;
    var end = e.selectionEnd;
    return e.value.substring(start, end);
    }
    else return "";
    }

    3.文本对象的 select()选定文本对象的文本

    4.一般的对象在表单域中提交信息的长度不能超过256个字节,超过过时用文本区域对象type="textarea"




  • 相关阅读:
    javascript入门教程笔记
    杭电2025
    杭电 2024
    杭电2019
    UEditor编辑器上传图片开发流程
    js操作textarea方法集合
    ueditor编辑器和at.js集成
    js分页算法
    js获取url中的参数
    第7章函数表达式笔记
  • 原文地址:https://www.cnblogs.com/ylemzhang/p/1911337.html
Copyright © 2011-2022 走看看