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"




  • 相关阅读:
    回溯算法(DFS:深度优先)
    KNN原理和实现
    Anaconda虚拟环境控制
    c++容器
    最坏情况为线性时间的选择算法
    JVM原理解析
    substr、substring和slice的区别
    word-wrap与break-word属性的区别
    js修改伪类的值
    快速批量删除文件名中相同的文字
  • 原文地址:https://www.cnblogs.com/ylemzhang/p/1911337.html
Copyright © 2011-2022 走看看