最实用JS 留着学习
1、A标签删除
function input(){ var b = window.confirm("确认要删除本条信息!"); if(b==true){ return true; }else{ return false; } }
2、按钮删除 function input(){ var b = window.confirm("确认要删除本条信息!"); if(b==true){ return document.myform.submit(); }else{ return false; } }
3、验证位数、个数、是否为空等 function inputName(){ var name = document.myForm.name.value; var count = 0 ; for( var i = 0 ; i< name.length ; i++){ var k = name.charCodeAt(i); if( k > 255 ){ count += 2; }else{ count += 1 ; } } if(document.myForm.name.value == null || document.myForm.name.value == "") { document.getElementById("errName").innerHTML="<font color='red' size='-1'>姓名不能为空</font>"; return ; }else if( count > 20 ){ document.getElementById("errName").innerHTML="<font color='red' size='-1'>姓名字节数只能为20</font>"; return ; }else{ document.getElementById("errName").innerHTML="<font color='red' size='-1'>*</font>"; return true; } }
function input(){ if(inputName() && inputPass()){ return document.myForm.submit(); }else{ return false; } }
4、判断radio是否选中 function input(){ var i = document.getElementsByName("nam"); if(i.checked == true ){ return true; }else{ for(var j = 0 ; j < i.length; j++){ if( i[j].checked == true){ return true; } } alert("请先选择!"); return false; } }
5、判断字符的非法性 var name=document.myform.txtUser; for(var i=0;i<name.value.length;i++){ var charTest=name.value.toLowerCase().charAt(i); if((!(charTest<='9' && charTest>='0')) && (!(charTest<='z' && charTest>='a')) && (charTest!='_')){ alert("用户名含非法字符,只能包括a-z,0-9和下划线"); name.select(); return false; } } var name=document.myform.txtUser; for(var i=0;i<name.value.length;i++){ var charTest=name.value.substring(i,i+1); if(charTest < 9 || charTest > 0 ){ alert("用户名含非法字符、数字"); name.select(); return false; } } 6、验证日期格式 if(name.value.charAt(4)!="-" || name.value.charAt(7)!="-"){ document.getElementById("Date").innerHTML="<font color='red' size='-1'>格式为yyyy-mm-dd 格式不正确</font>"; return ;
7、判断价格
function checek4(){ var myDiv5=document.getElementById("ijg"); myDiv5.innerHTML=""; var strjg=document.myForm.jg.value; if(strjg.length==0){ myDiv5.innerHTML="<font color='red' size='-1'>商品价格不能为空</font>"; return false; }else if(strjg<0){ myDiv5.innerHTML="<font color='red' size='-1'>商品价格不能为负</font>"; return false; }else if(isNaN(strjg)){ myDiv5.innerHTML="<font color='red' size='-1'>商品价格为数字</font>"; return false; } return true; }
8、<!--email检查--> if(document.myform.email.value==""){ alert("请输入email!"); document.myform.email.focus(); document.myform.email.select(); return false; }else if(document.myform.email.value.indexOf('@',0)==-1){ alert("请输入正确的电子邮件!"); document.myform.email.focus(); document.myform.email.select(); return false; }
9、下拉列表选择 function changeCity(){ var City=new Array(); City["湖南"]=["长沙","益阳"]; City["湖北"]=["武汉","公安"]; var selProvince=document.myform.selProvince.value; var citys; document.myform.selCity.options.length=0; for(var j in City[selProvince]){ citys=new Option(City[selProvince][j],City[selProvince][j]); document.myform.selCity.options.add(citys); }
}
<SELECT name="selProvince" id="selProvince" onChange="changeCity()" style="WIDTH: 130px"> <OPTION>--选择省份--</OPTION> <option value="湖南">湖南</option> <option value="湖北">湖北</option> </SELECT> <SELECT name="selCity" id="selCity" style="WIDTH: 130px"> <OPTION>--选择城市--</OPTION></SELECT>
10、接口可以继承接口,接口不可以实现接口,接口不可以实例化,接口不可以被继承 抽象类可以被继承,抽象类不可以实例化,
secpol.msc
function selectAll(checked) { var cbs = $("input[type=checkbox]"); cbs.each(function () { this.checked = checked; }); } function isSelectAll() { var cbs = $("input[type=checkbox]"); var count = 0; for (var i = 1, len = cbs.length - 1; i < len; i++) { if (cbs[i].checked) count++; } return (count == cbs.length - 2); } function getSelect() { var cbs = $("input[type=checkbox]"); var arr = []; for (var i = 1, len = cbs.length - 1; i < len; i++) { if (cbs[i].checked) arr.push(cbs[i]); } return arr; } // function batchsubmit() { // var cbs = $("input[type=checkbox]"); // var arr = getSelect(); // var infoids = []; // if (!arr.length) { alert("请先选择职位!"); return; } // for (var i = 0, len = arr.length; i < len; i++) { // infoids.push($(arr[i]).attr("infoid")); // } // var url = "http://jianli.58.com/sendselectjobapply/?infoids=" + infoids.join(","); // setbg("批量投递简历", 400, 150, url, true); // } $(function () { var cbs = $("input[type=checkbox]"); alert(cbs.length); for (var i = 1, len = cbs.length - 1; i < len; i++) { cbs[i].onclick = function () { if (isSelectAll()) { cbs[0].checked = true;cbs[cbs.length - 1].checked = true;} else {cbs[0].checked = false;cbs[cbs.length - 1].checked = false;} } } cbs[0].onclick = function () { selectAll(this.checked == true); } cbs[cbs.length - 1].onclick = function () { selectAll(this.checked == true); } });
function checkOne() { var o = document.getElementsByTagName("input"); var numLength = 0; for (i = 0; i < o.length; i++) { if (o[i].type=="checkbox" & o[i].checked & o[i].name != "ctl00$CP_Main$chkDiscount" & o[i].name != "chkAll" ) { numLength ++; } } if(numLength < 1) { alert("请至少选择一项进行操作!"); return false; }else { return true; } }
//管理操作所需的所有函数 //全选取消按钮函数,调用样式如:<利用Jquery> function checkAll(chkobj){ if($(chkobj).text()=="全选") { $(chkobj).text("取消"); $(".checkall input").attr("checked", true); }else{ $(chkobj).text("全选"); $(".checkall input").attr("checked", false); } }
$(function() { $('#lbtnDel').click(function() { if ($(":checkbox[checked = true]").size() < 1) { alert("最少选择一个复选框!"); return false; } return confirm('确定要执行操作吗? '); }); })
$(function() { $('#lbtnAdd').click(function() { if ($(":checkbox[checked = true]").size() < 1) { alert("最少选择一个复选框!"); return false; } return confirm('确定要执行操作吗? '); }); })
------------Repeater全选--------------------- //checkbox全选 function rptCheckAll(parentChk,ChildId,parentID) { var oElements = document.getElementsByTagName("INPUT"); var bIsChecked = parentChk.checked; for(i=0; i<oElements.length;i++) { if( IsCheckBox(oElements[i]) && IsMatch(oElements[i].id, ChildId,parentID)) { oElements[i].checked = bIsChecked; } } } //Radio全选 function rptCheckRadioAll(parentChk,ChildId,parentID) { var oElements = document.getElementsByTagName("INPUT"); var bIsChecked = parentChk.checked; for(i=0; i<oElements.length;i++) { if( IsRadioCheckBox(oElements[i]) && IsMatch(oElements[i].id, ChildId,parentID)) { oElements[i].checked = bIsChecked; } } } function IsMatch(id, ChildId,parentID) { var sPattern ='^.*'+parentID+'.*'+ChildId+'.*$'; var oRegExp = new RegExp(sPattern); if(oRegExp.exec(id)) return true; else return false; } function IsRadioCheckBox(chk) { if(chk.type == 'radio') return true; else return false; } function IsCheckBox(chk) { if(chk.type == 'checkbox') return true; else return false; } function rptOperateAll(ChildId,parentID) { var oElements = document.getElementsByTagName("INPUT"); var bools = false; for(i=0; i<oElements.length;i++) { if(IsMatch(oElements[i].id, ChildId,parentID) && IsCheckBoxChecd(oElements[i])) { bools = true; break; } } if(bools) { if(confirm("确定要执行操作吗?")) { return true; } } else { alert("请至少选择一项操作!"); } return false; } function IsCheckBoxChecd(chk) { if(chk.type == 'checkbox' && chk.checked == true) return true; else return false; } ----------------------判断价格---------------------------- function inputNum(obj) { if(isNaN(obj.value)) { obj.value = ""; obj.select(); } } function inputCount(obj) { if(obj.value.length>0) { var patrn=/^[0-9]{1,5}$/; if (!patrn.exec(obj.value)) { var ss = patrn.exec(obj.value); obj.value = ""; obj.select(); return false; } } } ---------------------------------IE7以上滤镜效果上传带预览JS------------------- function CheckImgCss(s,img) { if (!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(s.value)) { alert('只能上传jpg,bmp,gif,png格式图片!'); s.outerHTML = s.outerHTML; } else { var imgs = document.getElementById(img); imgs.src = ""; imgs.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src=s.value; imgs.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod="scale"; } } function clearFileInput(img,file){ if(file.value.length > 0) { var form=document.createElement('form'); document.body.appendChild(form); //记住file在旧表单中的的位置 var pos=file.nextSibling; var pos1 = img.nextSibling; form.appendChild(file); form.appendChild(img); form.reset(); pos.parentNode.insertBefore(file,pos); pos1.parentNode.insertBefore(img,pos1); document.body.removeChild(form); img.src="ImageLoad/logo.gif"; } else { alert("您没有上传图片,不能进行该操作!"); } } ----------------------------分享到人人,新浪,网易等------------------------------------------------------------- 分享给好友: <a href="javascript:void(0);" onclick="ShareLink('kaixin001');return false;" class="kx">开心</a> <a href="javascript:void(0);" onclick="ShareLink('renren');return false;" class="renr">人人</a> <a href="javascript:void(0);" onclick="ShareLink('douban');return false;" class="db">豆瓣</a> <a href="javascript:void(0);" onclick="ShareLink('tsina');return false;" class="xl">新浪微博</a> <a href="javascript:void(0);" onclick="ShareLink('t163');return false;" class="wy">网易微博</a>
/* 分享到 */ function ShareLink(m) { if (m == "baidu") { window .open('http://cang.baidu.com/do/add?it=' + encodeURIComponent(document.title.substring(0, 76)) + '&iu=' + encodeURIComponent(location.href) + '&fr=ien#nw=1', 'baidu', 'scrollbars=no,width=600,height=450,status=no,resizable=yes,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 450) / 2); } else if (m == "qq") { window .open( 'http://shuqian.qq.com/post?from=3&title=' + encodeURIComponent(document.title) + '&uri=' + encodeURIComponent(document.location.href) + '&jumpback=2&noui=1', 'favit', 'width=930,height=470,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes,left=' + (screen.width - 930) / 2 + ',top=' + (screen.height - 470) / 2); } else if (m == "tsina") { void ((function(s, d, e) { try { } catch (e) { } var f = 'http://v.t.sina.com.cn/share/share.php?', u = d.location.href, p = [ 'url=', e(u), '&title=', e(d.title), '&appkey=330242870'] .join(''); function a() { if (!window .open( [f, p].join(''), 'mb', [ 'toolbar=0,status=0,resizable=1,width=620,height=450,left=', (s.width - 620) / 2, ',top=', (s.height - 450) / 2].join(''))) u.href = [f, p].join(''); } ; if (/Firefox/.test(navigator.userAgent)) { setTimeout(a, 0) } else { a() } })(screen, document, encodeURIComponent)); } else if (m == "douban") { void (function() { var d = document, e = encodeURIComponent, s1 = window.getSelection, s2 = d.getSelection, s3 = d.selection, s = s1 ? s1() : s2 ? s2() : s3 ? s3.createRange().text : '', r = 'http://www.douban.com/recommend/?url=' + e(d.location.href) + '&title=' + e(d.title) + '&sel=' + e(s) + '&v=1', x = function() { if (!window .open(r, 'douban', 'toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=355,left=' + (screen.width - 450) / 2 + ',top=' + (screen.height - 330) / 2)) location.href = r + '&r=1' }; if (/Firefox/.test(navigator.userAgent)) { setTimeout(x, 0) } else { x() } })(); } else if (m == "renren") { // 官方分享方式1 // var connect_url = "http://www.connect.renren.com"; // var url = window.location.href; // var addQS = function(url, qs) { // var a = []; // for ( var k in qs) // if (qs[k]) // a.push(k.toString() + '=' + encodeURIComponent(qs[k])); // return url + '?' + a.join('&'); // } // var href = addQS(connect_url + '/sharer.do', { // 'url' : url, // 'title' : url == window.location.href ? document.title : null // }); // window.open(href, 'sharer', // 'toolbar=0,status=0,width=550,height=400,left=' // + (screen.width - 550) / 2 + ',top=' // + (screen.height - 500) / 2);
// 官方分享方式2 void ((function(s, d, e) { if (/renren\.com/.test(d.location)) return; var f = 'http://share.renren.com/share/buttonshare.do?link=', u = d.location, l = d.title, p = [ e(u), '&title=', e(l)].join(''); function a() { if (!window .open( [f, p].join(''), 'xnshare', [ 'toolbar=0,status=0,resizable=1,width=626,height=436,left=', (s.width - 626) / 2, ',top=', (s.height - 436) / 2].join(''))) u.href = [f, p].join(''); } ; if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a(); })(screen, document, encodeURIComponent)); } else if (m == "kaixin001") { var kw = window .open( '', 'kaixin001', 'toolbar=no,titlebar=no,status=no,menubar=no,scrollbars=no,location:no,directories:no,width=570,height=350,left=' + (screen.width - 570) / 2 + ',top=' + (screen.height - 420) / 2); var tempForm = kw.document.createElement('form'); function openPostWindow(url, data, name) { var tempForm = document.createElement('form'); tempForm.id = 'tempForm1'; tempForm.method = 'post'; tempForm.action = url; tempForm.target = 'kaixin001'; var hideInput = document.createElement('input'); hideInput.type = 'hidden'; hideInput.name = 'rcontent'; hideInput.value = data; tempForm.appendChild(hideInput); document.body.appendChild(tempForm); tempForm.submit(); document.body.removeChild(tempForm); } function add2Kaixin001() { var u = document.location.href; var t = document.title; var c = '' + (document.getSelection ? document.getSelection() : document.selection.createRange().text); var iframec = ''; var url = 'http://www.kaixin001.com/repaste/bshare.php?rtitle=' + encodeURIComponent(t) + '&rurl=' + encodeURIComponent(u) + '&from=maxthon'; var data = encodeURIComponent(c); openPostWindow(url, c, '_blank') } add2Kaixin001(); } else if (m == "google") { void (function() { var a = window, b = document, c = encodeURIComponent, d = a .open( 'http://www.google.com/bookmarks/mark?op=edit&hl=zh-CN&output=popup&bkmk=' + c(b.location) + '&title=' + c(b.title), 'bkmk_popup', 'left=' + ((a.screenX || a.screenLeft) + 10) + ',top=' + ((a.screenY || a.screenTop) + 10) + ',height=420px,width=550px,resizable=1,alwaysRaised=1'); a.setTimeout(function() { d.focus() }, 300) })(); } else if (m == "taojianghu") { window.open("http://share.jianghu.taobao.com/share/addShare.htm?url=" + encodeURIComponent(document.location.href), 'taojianghu', 'toolbar=0,status=0,width=550,height=400,left=' + (screen.width - 550) / 2 + ',top=' + (screen.height - 500) / 2); } else if (m == "gmail") { var a = window, b = document, c = encodeURIComponent; var w = window.open( "https://mail.google.com/mail/?view=cm&fs=1&tf=1&ui=2&shva=1&to&su=" + c(b.title) + "&body=" + c(b.location), 'gmail', 'width=' + (window.innerWidth * 0.57) + ',height=' + (window.innerHeight * 4 / 5) + ',left=' + ((a.screenX || a.screenLeft) + 10) + ',top=' + ((a.screenY || a.screenTop) + 10)); } else if (m == "yahoo") { window .open('http://myweb.cn.yahoo.com/popadd.html?url=' + encodeURIComponent(document.location.href) + '&title=' + encodeURIComponent(document.title), 'Yahoo', 'scrollbars=yes,width=440,height=440,left=80,top=80,status=yes,resizable=yes');
} else if (m == "douban9") { void (function() { var d = document, e = encodeURIComponent, s1 = window.getSelection, s2 = d.getSelection, s3 = d.selection, s = s1 ? s1() : s2 ? s2() : s3 ? s3.createRange().text : '', r = 'http://www.douban.com/recommend/?url=' + e(d.location.href) + '&title=' + e(d.title) + '&sel=' + e(s) + '&v=1&n=1', x = function() { if (!window .open(r, 'douban9', 'toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330')) location.href = r + '&r=1' }; if (/Firefox/.test(navigator.userAgent)) { setTimeout(x, 0) } else { x() } })(); } else if (m == "115") { var sel = '' + (document.getSelection ? document.getSelection() : document.selection.createRange().text); var url = document.location.href; var title = document.title; var c = encodeURIComponent; void (window.open('http://fav.115.com/?ac=add&title=' + c(title) + '&url=' + c(url) + '&c=' + c(sel), '115', 'toolbar=0,status=0,width=780,height=700,left=' + (screen.width - 780) / 2 + ',top=' + (screen.height - 700) / 2)); } else if (m == "51") { try { var w = window.open( "http://share.51.com/share/share.php?type=8&title=" + encodeURIComponent(document.title) + '&vaddr=' + encodeURIComponent(document.location), '51', 'toolbar=0,status=0,width=780,height=700,left=' + (screen.width - 780) / 2 + ',top=' + (screen.height - 700) / 2); window.opener.focus(); } catch (e) { } } else if (m == "tsohu") {// 非官方 void ((function(s, d, e) { var f = 'http://t.sohu.com/third/post.jsp?link=', u = d.location; function a() { if (!window .open( [f, e(u)].join(''), 'tsohu', [ 'toolbar=0,status=0,resizable=1,width=660,height=470,left=', (s.width - 660) / 2, ',top=', (s.height - 470) / 2].join(''))) u.href = [f, e(u)].join(''); } ; if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a(); })(screen, document, encodeURIComponent)); } else if (m == "leshou") { window .open('http://leshou.com/post?act=shou&reuser=&url=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title) + '&intro=&tags=&tool=1', 'leshou', 'scrollbars=yes,width=700,height=500,left=80,top=80,status=no,resizable=yes'); return false; } else if (m == "vivi") { var sel = '' + (document.getSelection ? document.getSelection() : document.selection.createRange().text); var url = document.location.href; var title = document.title; void (window .open('http://vivi.sina.com.cn/collect/icollect.php?title=' + escape(title) + '&url=' + escape(url) + '&desc=' + escape(sel), '_blank', 'scrollbars=no,width=480,height=480,left=75,top=50,status=no,resizable=yes')) } else if (m == "bai") { void ((function(s, d, e) { var f = 'http://bai.sohu.com/share/blank/addbutton.do?link=', u = d.location, l = d.title, p = [ e(u), '&title=', e(l)].join(''); function a() { if (!window .open( [f, p].join(''), 'sohushare', [ 'toolbar=0,status=0,resizable=1,width=480,height=340,left=', (s.width - 480) / 2, ',top=', (s.height - 340) / 2].join(''))) u.href = [f, p].join(''); } ; if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a(); })(screen, document, encodeURIComponent)); } else if (m == "qzone") {// 未开放分享 window.open( "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=" + encodeURIComponent(document.location), 'qzone', 'toolbar=0,status=0,width=900,height=760,left=' + (screen.width - 900) / 2 + ',top=' + (screen.height - 760) / 2); } else if (m == "live") { window .open( "https://skydrive.live.com/sharefavorite.aspx/.SharedFavorites/?marklet=1&mkt=zh-CN&top=1&url=" + encodeURIComponent(document.location) + "&title=" + encodeURIComponent(document.title), 'live', 'toolbar=0,status=0,width=850,height=530,left=' + (screen.width - 850) / 2 + ',top=' + (screen.height - 530) / 2); } else if (m == "greader") { var b = document.body; var GR________bookmarklet_domain = 'http://www.google.com'; if (b && !document.xmlVersion) { void (z = document.createElement('script')); void (z.src = 'http://www.google.com/reader/ui/link-bookmarklet.js'); void (b.appendChild(z)); } else { } } else if (m == "itieba") {// 未开放分享 var sendT = { getContent: function() { var allPageTagss = document.getElementsByTagName("div"); for (var i = 0; i < allPageTagss.length; i++) { if (allPageTagss[i].className == 'content') { return allPageTagss[i].innerHTML; } else if (allPageTagss[i].className == 'content_txt') {
return allPageTagss[i].getElementsByTagName("P")[0].innerHTML; }
} } } var itieba_share = 'http://tieba.baidu.com/i/sys/share?link=' + encodeURIComponent(window.location.href) + '&type=' + encodeURIComponent('text') + '&title=' + encodeURIComponent(document.title.substring(0, 76)) + '&content=' + encodeURIComponent(sendT.getContent()); if (!window .open(itieba_share, 'itieba', 'toolbar=0,resizable=1,scrollbars=yes,status=1,width=626,height=436')) { location.href = itieba_share; } } else if (m == "hexun") { var t = document.title; var u = location.href; var e = document.selection ? (document.selection.type != 'None' ? document.selection .createRange().text : '') : (document.getSelection ? document.getSelection() : ''); void (window.open('http://bookmark.hexun.com/post.aspx?title=' + escape(t) + '&url=' + escape(u) + '&excerpt=' + escape(e), 'HexunBookmark', 'scrollbars=no,width=600,height=580,status=no,resizable=yes,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 580) / 2)); } else if (m == "t163") {// 待完善--非官方 (function() { var url = 'link=http://www.shareto.com.cn/&source=' + encodeURIComponent('网易新闻 ') + '&info=' + encodeURIComponent(document.title) + ' ' + encodeURIComponent(document.location.href); window .open( 'http://t.163.com/article/user/checkLogin.do?' + url + '&' + new Date().getTime(), 't163', 'height=330,width=550,top=' + (screen.height - 280) / 2 + ',left=' + (screen.width - 550) / 2 + ', toolbar=no, menubar=no, scrollbars=no,resizable=yes,location=no, status=no'); })() } else if (m == "xianguo") { void (function() { var d = document, e = encodeURIComponent, s1 = window.getSelection, s2 = d.getSelection, s3 = d.selection, s = s1 ? s1() : s2 ? s2() : s3 ? s3.createRange().text : '', r = 'http://xianguo.com/service/submitfav/?link=' + e(d.location.href) + '&title=' + e(d.title) + '¬es=' + e(s), x = function() { if (!window .open(r + '&r=0', 'xgfav', 'toolbar=0,resizable=1,scrollbars=yes,status=1,width=800,height=600')) location.href = r + '&r=1' }; if (/Firefox/.test(navigator.userAgent)) { setTimeout(x, 0) } else { x() } })() } else if (m == 'hotmail') { window.open("http://mail.live.com/secure/start?action=compose&subject=" + encodeURIComponent(document.title) + "&body=" + encodeURIComponent(document.location.href), 'hotmail', 'toolbar=0,status=0,width=1010,height=700,left=' + (screen.width - 1010) / 2 + ',top=' + (screen.height - 700) / 2); } else if (m == "delicious") { (function() { f = 'http://delicious.com/save?url=' + encodeURIComponent(window.location.href) + '&title=' + encodeURIComponent(document.title) + '&v=5&'; a = function() { if (!window .open(f + 'noui=1&jump=doclose', 'deliciousuiv5', 'location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550')) location.href = f + 'jump=yes' }; if (/Firefox/.test(navigator.userAgent)) { setTimeout(a, 0) } else { a() } })() } else if (m == "digg") { window.open("http://digg.com/submit?type=0&url=" + encodeURIComponent(window.location.href), 'digg', 'toolbar=0,status=0,width=965,height=700,left=' + (screen.width - 965) / 2 + ',top=' + (screen.height - 700) / 2); } else if (m == "translate") { var t = ((window.getSelection && window.getSelection()) || (document.getSelection && document.getSelection()) || (document.selection && document.selection.createRange && document.selection .createRange().text)); var e = (document.charset || document.characterSet); if (t != '') { window.open('http://translate.google.cn/?text=' + t + '&hl=zh-CN&langpair=auto|zh-CN&tbb=1&ie=' + e, 'gtranslate'); } else { window.open('http://translate.google.cn/translate?u=' + encodeURIComponent(location.href) + '&hl=zh-CN&langpair=auto|zh-CN&tbb=1&ie=' + e, 'gtranslate'); } ; } else if (m == "buzz") { window .open( "http://www.google.com/buzz/post?hl=zh-CN&url=" + encodeURIComponent(window.location.href), 'buzz', "width=716,height=480,location=yes,scrollbars=yes,menubar=no,toolbar=no,dialog=yes,alwaysRaised=yes"); } else if (m == "pdf") { var authorId = "ECF83C2F-F3A3-45DE-8A44-2A36A9A9A1FB"; var pageOrientation = "1"; var topMargin = "0.5"; var bottomMargin = "0.5"; var leftMargin = "0.5"; var rightMargin = "0.5"; function savePageAsPDF() { var sUriRequest = ""; sUriRequest = "author_id=" + authorId; sUriRequest += "&page=" + pageOrientation; sUriRequest += "&top=" + topMargin; sUriRequest += "&bottom=" + bottomMargin; sUriRequest += "&left=" + leftMargin; sUriRequest += "&right=" + rightMargin; var pURL = "http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL=" + escape(document.location.href) + "&" + sUriRequest; window .open(pURL, "PDFOnline", "scrollbars=yes,resizable=yes,width=920,height=800,menubar,toolbar,location"); } savePageAsPDF(); } else if (m == "hi") { window .open( 'http://apps.hi.baidu.com/share/?url=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title), 'baiduhi', 'scrollbars=no,width=820,height=550,status=no,resizable=yes,left=' + (screen.width - 820) / 2 + ',top=' + (screen.height - 550) / 2); } else if (m == "reddit") { var href = 'http://www.reddit.com/submit?url=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title); window.open(href, 'reddit', 'toolbar=0,status=0,width=900,height=740,left=' + (screen.width - 900) / 2 + ',top=' + (screen.height - 740) / 2); } else if (m == "t139") { window.open('http://www.139.com/share/share.php?title=' + encodeURIComponent(document.title) + '&url=' + encodeURIComponent(location.href), 't139', 'width=490,height=340,left=' + (screen.width - 490) / 2 + ',top=' + (screen.height - 340) / 2); } else if (m == "myspace") { (function() { window.open( 'http://www.myspace.cn/Modules/PostTo/Pages/DefaultMblog.aspx?t=' + encodeURIComponent(document.title) + '&u=' + encodeURIComponent(location.href) + '&source=bookmark', 'myspace', 'width=495,height=450,resizable=yes,left=' + (screen.width - 495) / 2 + ',top=' + (screen.height - 450) / 2); })(); } else if (m == "ymail") { window.open("http://compose.mail.yahoo.com/?subject=" + encodeURIComponent(document.title) + "&body=" + encodeURIComponent(document.location), 'ymail', 'toolbar=0,status=0,width=760,height=670,left=' + (screen.width - 760) / 2 + ',top=' + (screen.height - 670) / 2); } else if (m == "csdn") { var d = document; var t = d.selection ? (d.selection.type != 'None' ? d.selection .createRange().text : '') : (d.getSelection ? d.getSelection() : ''); void (saveit = window .open('http://wz.csdn.net/storeit.aspx?t=' + escape(d.title) + '&u=' + escape(d.location.href) + '&c=' + escape(t), 'csdn', 'scrollbars=no,width=600,height=310,status=no,resizable=yes,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 310) / 2)); saveit.focus(); } else if (m == "youdao") { void (window .open( 'http://shuqian.youdao.com/manage?a=popwindow&title=' + encodeURI(document.title) + '&url=' + encodeURI(document.location), 'youdao', 'height=200, width=590,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,left=' + (screen.width - 590) / 2 + ',top=' + (screen.height - 200) / 2)); } return false; };
------------------------------------QQ,MSN的网页点击弹出聊天窗口----------------------------------------------------------- <a target="blank" href="http://wpa.qq.com/msgrd?V=1&Uin=<%=QQ %>&Site=爱爸妈网在线咨询&Menu=yes"> <img src="../images/qq.gif" alt="点击这里给我发消息" align="absmiddle"></a> <a target="blank" href="msnim:chat?contact=<%=MSN %>"> <img src="../images/msn.gif" /></a>
最实用JS 留着学习的更多相关文章
- Underscore.js 源码学习笔记(下)
上接 Underscore.js 源码学习笔记(上) === 756 行开始 函数部分. var executeBound = function(sourceFunc, boundFunc, cont ...
- Underscore.js 源码学习笔记(上)
版本 Underscore.js 1.9.1 一共 1693 行.注释我就删了,太长了… 整体是一个 (function() {...}()); 这样的东西,我们应该知道这是一个 IIFE(立即执行 ...
- JS做深度学习3——数据结构
最近在上海上班了,很久没有写博客了,闲下来继续关注和研究Tensorflow.js 关于深度学习的文章我也已经写了不少,部分早期作品可能包含了不少错误的认识,在后面的博文中会改进或重新审视. 今天聊聊 ...
- JS做深度学习2——导入训练模型
JS做深度学习2--导入训练模型 改进项目 前段时间,我做了个RNN预测金融数据的毕业设计(华尔街),当时TensorFlow.js还没有发布,我不得已使用了keras对数据进行了训练,并且拟合好了不 ...
- js callee,caller学习
原文地址:js callee,caller学习 /* * caller 返回一个对函数的引用,该函数调用了当前函数. * 如果函数是由顶层调用的,那么 caller包含的就是 null . * 如果在 ...
- 【09-23】js原型继承学习笔记
js原型继承学习笔记 function funcA(){ this.a="prototype a"; } var b=new funcA(); b.a="object a ...
- 实用js代码大全
实用js代码大全 //过滤数字 <input type=text onkeypress="return event.keyCode>=48&&event.keyC ...
- Knockout.Js官网学习(系列)
1.Knockout.Js官网学习(简介) 2.Knockout.Js官网学习(监控属性Observables) Knockout.Js官网学习(数组observable) 3.Knockout.Js ...
- json2.js的初步学习与了解
json2.js的初步学习与了解,想要学习json的朋友可以参考下. json2.js的初步学习与了解 1.)该js的下载地址是:http://www.json.org/json2.js 2.)在页面 ...
随机推荐
- 希尔伯特曲线python3实现
需要OpenGL库:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl #coding:utf-8 from OpenGL.GL import * ...
- linux shell 判断空字符串的几种方法!
在书写linux shell 脚本我们经常会遇到,对一个字符串是否为空进行判断,下面我对几种常用的方法进行了一个总结: 1.-z判断 -z string True if the length of s ...
- Nacos服务心跳和健康检查源码介绍
服务心跳 Nacos Client会维护一个定时任务通过持续调用服务端的接口更新心跳时间,保证自己处于存活状态,防止服务端将服务剔除,Nacos默认5秒向服务端发送一次,通过请求服务端接口/insta ...
- Arduino字符串笔记
Arduino里的字符串笔记 1 字符串转数字 String To Int /* 使用String.toInt()将字符串转为数字示例 */ String inString = "" ...
- Hive调优相关
前言 Hive是由Facebook 开源用于解决海量结构化日志的数据统计,是基于Hadoop 的一个数据仓库工具,可以将结构化的数据文件映射为一张表,并提供类 SQL查询功能. 在资源有限的情况下,提 ...
- ElasticSearch结合Logstash(三)
一.Logstash简介 1,什么是Logstash Logstash 是开源的服务器端数据处理管道,能够同时从多个来源采集数据,转换数据,然后将数据发送到您最喜欢的"存储库"中. ...
- Codeforces Round #529 (Div. 3) F. Make It Connected (贪心,最小生成树)
题意:给你\(n\)个点,每个点都有权值,现在要在这\(n\)个点中连一颗最小树,每两个点连一条边的边权为两个点的点权,现在还另外给了你几条边和边权,求最小权重. 题解:对于刚开始所给的\(n\)个点 ...
- PowerShell随笔1---背景
既然是随笔,那就想到什么说什么,既会分享主题知识,也会分享一些其他技巧和个人学习方法,供交流. 我一般学习一个东西,我都会问几个问题: 这东西是什么? 这东西有什么用,为什么会出现,出现是为了解决什么 ...
- Leetcode(213)-打家劫舍II
你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金.这个地方所有的房屋都围成一圈,这意味着第一个房屋和最后一个房屋是紧挨着的.同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在 ...
- sql-libs(5)
直接只用floor报错注入 或者 update即可