时间:2021-05-26
纯粹是为了打发时间,手写了一个JS的 alert控件。
代码如下:
<html> <head> <script type="text/javascript"> var alertObj = new Object(); var generalStyle = { zIndex: 0, width: "200px", height: "100px", border: "thick solid #CCCCCC", background: "#FFFFFF", position: "absolute", top: "35%", left: "40%" } var txtStyle = { textAlign: "center" } var btnStyle = { position: "absolute", left: "40%", top: "70%", color: "#333333", fontWeight: "bold", outlineColor:"#3366FF", outlineStyle:"ridge", outlineWidth:"thin", //outline: "thin ridge #3366FF", innerHTML: "OK" } alertObj = { generalSet: generalStyle, txtSet: txtStyle, btnSet: btnStyle, isExist: false } alertObj.createComponent = function() { var component = document.createElement(arguments[0]); var styles = arguments[1]; for (var property in styles) { if (styles[property] != null) { try{ component.style[property] = styles[property]; }catch(err){ document.write(err.name+":"+property+"<br/>");//set property error! } } } return component; } alertObj.show = function() { if(!this.isExist){ this.isExist = true; var bodyObj = document.body; bodyObj.style.zIndex = -1; bodyObj.style.background = "#999999"; var divObj = this.createComponent("div", this.generalSet); var txtObj = this.createComponent("p", this.txtSet); txtObj.innerHTML = arguments[0]; var btnObj = this.createComponent("button", this.btnSet); btnObj.innerHTML = this.btnSet.innerHTML; btnObj.onclick = function() { bodyObj.style.zIndex=0; bodyObj.style.background=""; bodyObj.removeChild(divObj); if(alertObj.isExist){ alertObj.isExist = false; } } divObj.appendChild(txtObj); divObj.appendChild(btnObj); bodyObj.appendChild(divObj); } } function show(s) { alertObj.show(s); } </script> </head> <body> <p onclick="show('inner test');">Click show alert</p> </body> </html>声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
创建一个js文件,名为testClosure.js:(function(){functiona(){alert('iama');}outFunc=functio
JS设置控件enabled为可交互document.getElementById("控件ID").disabled="";JS设置控件enabled为不可交互d
Js代码复制代码代码如下:alert(1/3);//弹出:0.3333333333333333alert(0.09999999+0.00000001);//弹出
看到有朋友喜欢,放出下载点击下载此文件由于是为学习js而做的,所以代码写的自己都很不喜欢:(要继续写只能重写了,看时间吧。代码转移到prototype1.4增加
1利用js实现复制代码代码如下:if(!$this->userInfo){$alert_msg="激活链接错误";echo"alert('$alert_msg'