mirror of
https://gitee.com/layui/layui.git
synced 2025-05-17 13:39:37 +08:00
优化 ie8 .remove()
报错和复制时滚动条置底问题
This commit is contained in:
parent
5a00d0a32f
commit
cc9cdeb03e
@ -318,13 +318,16 @@
|
|||||||
try {
|
try {
|
||||||
navigator.clipboard.writeText(text).then(
|
navigator.clipboard.writeText(text).then(
|
||||||
options.done
|
options.done
|
||||||
).['catch'](options.error);
|
)['catch'](options.error);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
var elem = document.createElement('textarea');
|
var elem = document.createElement('textarea');
|
||||||
|
|
||||||
elem.value = text;
|
elem.value = text;
|
||||||
elem.style.position = 'absolute';
|
elem.style.position = 'fixed';
|
||||||
elem.style.opacity = '0';
|
elem.style.opacity = '0';
|
||||||
|
elem.style.top = '0px';
|
||||||
|
elem.style.left = '0px';
|
||||||
|
|
||||||
document.body.appendChild(elem);
|
document.body.appendChild(elem);
|
||||||
elem.select();
|
elem.select();
|
||||||
|
|
||||||
@ -333,9 +336,9 @@
|
|||||||
typeof options.done === 'function' && options.done();
|
typeof options.done === 'function' && options.done();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
typeof options.error === 'function' && options.error(err);
|
typeof options.error === 'function' && options.error(err);
|
||||||
|
} finally {
|
||||||
|
elem.remove ? elem.remove() : document.body.removeChild(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user