解决方案

超nb的网页标签弹窗js代码!

seo靠我 2023-09-22 18:03:16

首先说一下业务需求:

需要在当前各主流浏览器上从tab标签形式弹出一个页面,尽量不要以单独窗口弹出。

下面是网上搜集并修改、验证后的js代码,以备以后参阅。

function getUnionCookie(SEO靠我B) {var A = new RegExp(B + "=([^;]+)"), _ = A.exec(document.cookie), $ = "";if (_ != null) {try {$ =SEO靠我 decodeURI(_[1]);}catch (C) {}}return $; }function setUnionCookie(sName, sValue, oExpireSEO靠我s, sPath) {document.cookie = sName + "=" + escape(sValue) + ";expires=" + oExpires.toUTCString() + "SEO靠我;path=" + sPath; }//使用cookie控制每隔24小时弹一次,似乎不见效 function updateunionli() {var SEO靠我exp2 = new Date();exp2.setTime(exp2.getTime() + 24 * 60 * 60 * 1000);setUnionCookie("unionli_lc", 4 SEO靠我+ 1, exp2, /);var poped_statist = new Image();poped_statist.src = "http://www.anmeiqi.com/logo/anmeiSEO靠我qi.gif"; //广告的统计的url }var anmeiqi_url = http://www.anmeiqi.com/;//要推广的url vaSEO靠我r is_unionli_poped = getUnionCookie(unionlipop); if (!is_unionli_poped) {var unionli_pidSEO靠我x = getUnionCookie(unionli_lc);if (!unionli_pidx)unionli_pidx = 1;(function() {var aa_url = window.aSEO靠我nmeiqi_url;var _has2ap = 0;var ua = navigator.userAgent;var browser = {ie: /msie/i.test(ua),ie6: /msSEO靠我ie 6/i.test(ua),ie7: /msie 7/i.test(ua),ie8: /msie 8/i.test(ua),ie9: /msie 9/i.test(ua),360: /360se/SEO靠我i.test(ua),sogou: /;?se.+?MetaSr/i.test(ua),maxthon: /Maxthon/i.test(ua),tt: /TencentTraveler/i.testSEO靠我(ua),ff: /firefox/i.test(ua),webkit: /AppleWebKit/i.test(ua),opera: /Opera/i.test(ua),qqbrowser: /QQSEO靠我Browser/i.test(ua),theworld: /Theworld/i.test(ua)};function ev_op(e, event, func, act) {if (browser.SEO靠我ie)e[act === undefined ? attachEvent : detachEvent](on + event, func);elsee[act === undefined ? addESEO靠我ventListener : removeEventListener](event, func, false)}//弹窗效果顶层包装函数function pop(url, param) {if (!dSEO靠我ocument.body) {return setTimeout(function() {pop(url, param)}, 13)}try {if (browser[webkit] && browsSEO靠我er[maxthon]) {if (!core_pop(url)) {a_pop(url)}} else if (browser[tt]) {try {object_pop(url)} catch (SEO靠我e) {a_pop(url)}} else if (browser[sogou]) {if (!core_pop(url)) {a_pop(url)}} else if (browser[webkitSEO靠我] && browser[qqbrowser]) {if (!core_pop(url)) {click_pop(url)}} else if (browser[webkit] || browser[SEO靠我opera]) {a_pop(url)} else if (browser[theworld] && browser.ie6) {if (!object_pop2(url)) {a_pop(url)}SEO靠我} else if (browser[theworld] && browser.ie8) {if (!core_pop(url)) {try {object_pop(url)} catch (e) {SEO靠我click_pop(url)}}} else if (browser.ie6) {if (!core_pop(url)) {object_pop2(url)}} else if (browser.ieSEO靠我8) {if (!core_pop(url)) {document.onclick = function() {core_pop(url);document.onclick = null}}} elsSEO靠我e if (browser[ie]) {try {object_pop(url)} catch (e) {click_pop(url)}} else if (browser[ff]) {if (!coSEO靠我re_pop(url)) {click_pop(url)}} else {if (!core_pop(url)) {click_pop(url)}}_has2ap = 1;updateunionli(SEO靠我)} catch (e) {if (browser.ie7 || browser.ie8 || browser.ie9 || browser[qqbrowser]) {click_pop(url)} SEO靠我else {a_pop(url)}_has2ap = 1;updateunionli()}}function append(e) {for (var t in {body: 1}) {var ele SEO靠我= document.getElementsByTagName(t);for (var i = 0; i < ele.length; i++) {ele[i].insertBefore(e, ele[SEO靠我i].firstChild);return}}}function object_pop(url, param) {var object = document.createElement(object)SEO靠我;object.setAttribute(classid, CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6);object.style.cssText = posSEO靠我ition:absolute;left:1px;top:1px;width:1px;height:1px;;append(object);object.launchURL(url)}function SEO靠我object_pop2(url, param) {var object2 = document.createElement(object);object2.setAttribute(classid, SEO靠我clsid:2D360201-FFF5-11d1-8D03-00A0C959BC0A);object2.style.cssText = position:absolute;left:1px;top:1SEO靠我px;width:1px;height:1px;;append(object2);for (var i in object2) {try {(function(o) {})(object2[i])} SEO靠我catch (e) {}}setTimeout(function() {object2.DOM.Script.open(url, _blank, )}, 500)}//监视到mouseup事件后异步取SEO靠我消,然后弹窗function click_pop(url, param) {ev_op(document, mouseup, function(e) {e = e || window.event;e.SEO靠我canceBubble = true;ev_op(document, mouseup, arguments.callee, true);core_pop(url, param)})}function SEO靠我a_pop(url) {var a = document.createElement(a);a.href = url;a.target = _blank;var div = document.creaSEO靠我teElement(div);div.style.backgroundColor = #ffffff;a.style.filter = alpha(opacity=0);a.style.opacitySEO靠我 = 0;a.appendChild(div);append(a);a.style.display = block;a.style.cursor = default;a.style.position SEO靠我= absolute;a.style.left = 0px;a.style.top = 0px;a.style.zIndex = 999999;var i = setInterval(functionSEO靠我() {var d = document.documentElement || document.body;a.style.top = Math.max(document.documentElemenSEO靠我t.scrollTop, document.body.scrollTop) + px;div.style.width = Math.min(d.clientWidth, d.scrollWidth) SEO靠我+ px;div.style.height = d.clientHeight + px}, 200);a.onclick = function(e) {setTimeout(function() {aSEO靠我.parentNode.removeChild(a)}, 200);clearInterval(i)};a.onmouseup = function(e) {e = e || window.eventSEO靠我;e.canceBubble = true}}function core_pop(url, param) {var w = window.open(url, _blank, left=0,top=0,SEO靠我toolbar=yes,location=yes, + status=yes,menubar=yes,scrollbars=yes, + resizable=yes,width= + screen.wSEO靠我idth + ,height= + screen.height);return w}//调用弹窗函数入口setTimeout(function() {pop(aa_url, {a: 1,b: 2})}SEO靠我, 300);ev_op(window, beforeunload, function() {})})(); }

“SEO靠我”的新闻页面文章、图片、音频、视频等稿件均为自媒体人、第三方机构发布或转载。如稿件涉及版权等问题,请与 我们联系删除或处理,客服邮箱:html5sh@163.com,稿件内容仅为传递更多信息之目的,不代表本网观点,亦不代表本网站赞同 其观点或证实其内容的真实性。

网站备案号:浙ICP备17034767号-2