Aufgrund zahlreicher PopUp-Blocker macht ein PopUp und PopUnder nur Sinn, wenn man diesen in einer Interaktion verwendet, z. B. beim Klick auf einen Link. Dort schlagen in der Regel keine PopUp-Blocker an.
Die folgenden beiden Javascript-Funktionen beinhalten sogar eine Reload-Sperre via Cookie, so dass pro User der PopUnder/PopUp nur einmal pro Stunde angezeigt wird.
PopUnder:
<script type="text/javascript"> /** * PopUnder function * @param string - strUrl Url to popUnder content * @param string - strTitle Window title * @param int - intWidth Width of popUnder window * @param int - intHeight Height of popUnder window * @param string - strCookieName Name of reload block cookie */ function popUnder(strUrl,strTitle,intWidth,intHeight,strCookieName) { // Get cookie for reload block var strCookieValue = document.cookie; var strPattern = eval('/'+strCookieName+'=true/i'); // Check cookie if (!strCookieValue.match(strPattern)) { // Set cookie for reload block var objDate = new Date(); objDate = new Date(objDate.getTime()+1000*60*60); // Reload block for 1 hour document.cookie = strCookieName+'=true; expires='+objDate.toGMTString()+';'; // Set position var intLeft = (screen.width) ? (screen.width-intWidth)/2 : 100; var intTop = (screen.height) ? (screen.height-intHeight)/2 : 100; // PopUnder parameter var strParameter = 'width='+intWidth+',height='+intHeight+',top='+intTop+',left='+intLeft+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no,dependent=no'; var objWindow = window.open(strUrl,'',strParameter); // Set popUnder in the background objWindow.blur(); window.focus(); } } </script> <a href="#" onclick="popUnder('http://www.fburian.de','PopDown',800,600,'reloadCookie'); return false;">Klick here to open popUnder</a><br />
JavaScript: Das umfassende Handbuch für Einsteiger, Fortgeschrittene und Profis
PopUp:
<script type="text/javascript"> /** * PopUp function * @param string - strUrl Url to popup content * @param string - strTitle Window title * @param int - intWidth Width of popup window * @param int - intHeight Height of popup window * @param string - strCookieName Name of reload block cookie */ function popUp(strUrl,strTitle,intWidth,intHeight,strCookieName) { // Get cookie for reload block var strCookieValue = document.cookie; var strPattern = eval('/'+strCookieName+'=true/i'); // Check cookie if (!strCookieValue.match(strPattern)) { // Set cookie for reload block var objDate = new Date(); objDate = new Date(objDate.getTime()+1000*60*60); // Reload block for 1 hour document.cookie = strCookieName+'=true; expires='+objDate.toGMTString()+';'; // Set position var intLeft = (screen.width) ? (screen.width-intWidth)/2 : 100; var intTop = (screen.height) ? (screen.height-intHeight)/2 : 100; // Popup parameter var strParameter = 'width='+intWidth+',height='+intHeight+',top='+intTop+',left='+intLeft+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no,dependent=no'; var objWindow = window.open(strUrl,'',strParameter); // Set popup in the foreground objWindow.focus(); } } </script> <a href="#" onclick="popUp('http://www.fburian.de','PopUp',800,600,'reloadCookie'); return false;">Klick here to open popup</a>
Schönes Script-werd ich gleich ausprobieren. Danke.