Greasy Fork is available in English.

MyModal

原生js弹出层

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.org/scripts/463930/1177945/MyModal.js


作者
wish king
版本
0.0.1.20230419051637
创建于
2023-04-13
更新于
2023-04-19
大小
7.9 KB
许可证
暂无

简单js弹出层

截图:






在线预览:
https://jsrun.net/gddKp/embedded/all/light

使用示例:

document.querySelector("#test1").addEventListener("click", function(){
new MyModal({
top: '',
width: '50%',
height: 'auto',
borderRadius: '5px',
zIndex: 1010,
//null,不显示title
title: 'test1',
//支持HTML格式,null不显示content
content: 'Hello World!',
//closeText:null,不显示关闭按钮
closeText: '关闭',
closeWidth: '',
//okText:null,不显示ok按钮
okText: '好了',
okWidth: '',
//closeFn和okFn可以省略
closeFn: function (e) {
console.log('closeFn clicked');
e.myModal.close();
},
okFn: function (e) {
console.log('okFn clicked');
e.myModal.close();
}
}).show();
});