//js判断窗口是否是最大化(非最佳方式)
window.onresize = function(){
if(window.screen.availWidth - document.body.offsetWidth < 100){
alert("窗口最大化");
} else {
alert("窗口不是最大化");
}
}
//当前页面刷新 / 跳转 时提示实现
//js
var pb_strConfirmCloseMessage;
var pb_blnCloseWindow = false;
pb_strConfirmCloseMessage ="您真的要离开本页吗?";
function ConfirmClose() {
window.event.returnValue = pb_strConfirmCloseMessage;
pb_blnCloseWindow = true;
}
function ShowConfirmClose(blnValue) {
if(blnValue) {
document.body.onbeforeunload = ConfirmClose;
} else {
document.body.onbeforeunload = null;
}
}
//html
οnbefοreunlοad="ConfirmClose();" οnunlοad="ConfirmClose();">
//动态添加一行,删除一行(使用一个模板,隐藏)
function addRow(){
var tb = document.getElementById("tab1");//获取Table
var tbClone = document.getElementById("tab2");
//得到添加节点的位置
var newTrC = tb.insertRow(tb.rows.length);
var templateRow = tbClone.rows[0];
for(var i=0; i
{
tmp_cell = templateRow.cells[i].cloneNode(true);
newTrC.style.backgroundColor="#FAFAF1";
newTrC.appendChild(tmp_cell);
}
}
function delRow(obj){
$(obj).parents("tr").remove();
}
//动态添加多行多列
var tb = document.getElementById("myTable1");//获取Table
var tbClone =document.getElementById("myTable2");//模板table
for(var j=0;j //得到添加节点的位置 ===插入行 varnewTrC = tb.insertRow(tb.rows[j].length); vartemplateRow = tbClone.rows[j]; //===插入列 for(vari=0; i { tmp_cell =templateRow.cells[i].cloneNode(true); newTrC.style.backgroundColor="#FAFAF1"; newTrC.appendChild(tmp_cell); } } //js计算两个数的和 tot = (Number)(workP[i].value) + (Number)(tot); //js动态创建select 1.动态创建select function createSelect(){ function addOption(){ function removeAll(){ function removeOne(){ var obj=document.getElementByIdx_x('mySelect'); var obj=document.getElementByIdx_x('mySelect'); 复制代码 代码如下: 复制代码 代码如下: ======================end======================= //控制文本框输入字符 οnkeyup="this.value=this.value.replace(/\D/g,'.')" οnpaste="this.value=this.value.replace(/\D/g,'.')" //js控制文本框替换输入的特殊字符 οnkeyup=”this.value=this.value.replace(/[^u4e00-u9fa5w]/g,'');” //ajax $.ajax( { url: "us!isunalbed.do?uid=" + uid, dataType: "json", async:false, //同步执行 type: "post", //成功后调用 success: function(data) { dialogMessBox(data); } }); //js设置定时器 setInterval("winClose()",5000); //方法名 window.setInterval( function () { window.location.href =data[3]; } , 2000 ); //页面加载完毕就执行js方法 $(document).ready(function(){}) //页面调用窗口完毕后执行 window.close(); window.opener.location.reload(); //html拼接table + 转义字符 function addRow(){ var onP1 = "οnkeyup=\"this.value=this.value.replace(/\\D/g,'.')\"οnpaste='this.value=this.value.replace(/\\D/g,'.')\" "; var onP2 = "οnkeyup=\"this.value=this.value.replace(/\\D/g,'%')\"οnpaste='this.value=this.value.replace(/\\D/g,'%')\" "; var newTab = " +" +" " +" "
var mySelect = document.createElement_x("select");
mySelect.id = "mySelect";
document.body.appendChild(mySelect);
}
2.添加选项option
//根据id查找对象,
var obj=document.getElementByIdx_x('mySelect');
//添加一个选项
obj.add(new Option("文本","值"));
}
3.删除所有选项option
var obj=document.getElementByIdx_x('mySelect');
obj.options.length=0;
}
4.删除一个选项option
var obj=document.getElementByIdx_x('mySelect');
//index,要删除选项的序号,这里取当前选中选项的序号
var index=obj.selectedIndex;
obj.options.remove(index);
}
5.获得选项option的值
var index=obj.selectedIndex; //序号,取当前选中选项的序号
var val = obj.options[index].value;
6.获得选项option的文本
var index=obj.selectedIndex; //序号,取当前选中选项的序号
var val = obj.options[index].text;
7.修改选项option
var obj=document.getElementByIdx_x('mySelect');
var index=obj.selectedIndex; //序号,取当前选中选项的序号
var val = obj.options[index]=new Option("新文本","新值");
8.删除select
function removeSelect(){
var mySelect = document.getElementByIdx_x("mySelect");
mySelect.parentNode.removeChild(mySelect);
} οnkeyup="this.value=this.value.replace(/[^a-zA-Z\d\u4e00-\u95fa5]/g,'')"
οnpause="this.value=this.value.replace(/[^a-zA-Z\d\u4e00-\u95fa5]/g,'')"
" "
+"
+"
$("#myTable2").append(newTab);
}//html中冻结标题栏
//判断IE浏览器版本(?)
var b_name = navigator.appName;
var b_version = navigator.appVersion;
var version = b_version.split(";");
var trim_version = version[1].replace(/[ ]/g, "");
if (b_name == "Microsoft Internet Explorer") {
/*如果是IE9及以下*/
if (trim_version == "MSIE7.0" || trim_version == "MSIE6.0" || trim_version == "MSIE8.0" || trim_version == "MSIE9.0") {
alert("您的ie版本过低,为获得更好的体验,请更新您的版本!");
}
}