SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    unblockable popup

    My popup works on the onload event, so it's blocked. Not every user know how to show this popup even it is disabled, so I'm trying to find a some way...

    I found a code, here:

    Code:
    <html>
    <head>
    <style type="text/css">
    		html, body, #wrap { height:100% ; margin:0 ; overflow:hidden ; padding:0 ; width:100% }
    		a img { border:none }
    		a { text-decoration:none }
    		p { margin:0 ; padding:.5em 0 }
    		#wrap { background:#FFF ; color:#000 ; overflow:auto }
    			#wrap2 { padding-top:21px }
    		#pop { background:#DEDEFF ; border:2px solid #039 ; color:#000 ; left:100px ; position:absolute ; top:100px ; visibility:hidden ; width:200px }
    			#pop div { font-weight:bold ; text-align:right }
    		#close { background:#808080 ; font-weight:bold ; position:absolute ; right:0 ; text-align:right ; width:100% }
    			#close a span, #pop div a span  { background:#C00 ; color:#FFF ; padding:0 .5em }
    	</style>
    	<script type="text/javascript">
    		function countdown() {
    			setTimeout('pop()',90000);
    		}
    		function pop() {
    			document.getElementById('pop').style.visibility = "visible";
    			setTimeout('popunder()',300);
    		}
    		function popunder() {
    			document.getElementById('pop').style.visibility = "hidden";
    		}
    		function toggle() {
    			document.getElementById('close').style.display = "none";
    			document.getElementById('wrap').style.display = "none";
    			document.getElementById('pop').style.visibility = "visible";
    		}
    	</script>
    </head>
    
    <body id="home" onload="javascript:toggle();">
    
    <div id="close"><a href="javascript: self.close ()">X</a></div>
    
    <div id="pop">
    	<div><a href="javascript: self.close ()">X</a></div>
            <p>Content</p>
    	<p>Content</p>
    	<p>Content</p>
    	<p>Content</p>
    </div>
    
    <div id="wrap">
    	<div id="wrap2">
    	</div>
    </div>
    
    </body>
    </html>
    the problem is that I can't figure out how to close this window? any ideas? Somehow I need to disable a popup showing function, is that possible? slef.close doesn't work

  2. #2
    SitePoint Member
    Join Date
    Oct 2006
    Location
    Eindhoven, The Netherlands
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't close this "popup" using self.close() since it's not a window, but a div.
    You can however hide the div using the popunder() function which is in the <head>.
    This "closes" (hides) the popup.

    Your link to close the popup would look like this:
    Code:
    <a href="javascript: popunder()">X</a>

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi bauglir,

    Welcome to SPF!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •