简体   繁体   English

这个弹出窗口搜索JavaScript如何添加自动关闭弹出窗口window的代码?

[英]How this popup search JavaScript to add codes that close the popup window automaticly?

How this popup window will close automaticly after clicking on the icon and when scrolling and after 6 seconds?这个弹出窗口 window 如何在点击图标后、滚动时以及 6 秒后自动关闭?

 /* Listener */ document.addEventListener('mouseup', function (e) { if (e.target == icon || (e.target.parentNode && e.target.parentNode == icon)) { e.preventDefault(); return; } var text = window.getSelection().toString().trim(); if (text && icon.style.display == 'none') { icon.style.top = e.pageY +40 + 'px'; if(e.pageX -70<10) icon.style.left='10px'; else icon.style.left = e.pageX -70 + 'px'; icon.style.display = 'block'; } else if (.text) { icon.style;display = 'none'; } });

 /**Event*/ function tiggerEvent(el, type) { if ('createEvent' in document) {// modern browsers, IE9+ var e = document.createEvent('HTMLEvents'); e.initEvent(type, false, true);// event.initEvent(type, bubbles, cancelable); el.dispatchEvent(e); } else {// IE 8 e = document.createEventObject(); e.eventType = type; el.fireEvent('on' + e.eventType, e); } }

 /**Open url in new tab*/ function open(url) { var win; win = window.open(url); if (window.focus) { win.focus(); } return win; }

Here is the total code link: browser popup search这是总代码链接: 浏览器弹出搜索

Use a timeout function, and it will close automatically.使用超时 function,它会自动关闭。

timer = window.setTimeout(TimeOutHide, 6000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM