Sha256: c7e14a5815f5ead9676df26215b3b53c5d8be08448cc9a2109a88505af2c3d95

Contents?: true

Size: 653 Bytes

Versions: 23

Compression:

Stored size: 653 Bytes

Contents

// Code from https://stackoverflow.com/questions/5379120/get-the-highlighted-selected-text

function() {
    var text = "";
    var activeEl = document.activeElement;
    var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null;
    if (
        (activeElTagName == "textarea") || (activeElTagName == "input" &&
        /^(?:text|search|password|tel|url)$/i.test(activeEl.type)) &&
        (typeof activeEl.selectionStart == "number")
    ) {
        text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd);
    } else if (window.getSelection) {
        text = window.getSelection().toString();
    }
    return text;
}

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
watir-6.16.0 lib/watir/js_snippets/selectedText.js
watir-6.15.1 lib/watir/js_snippets/selectedText.js
watir-6.15.0 lib/watir/js_snippets/selectedText.js