Popup Script Javascript
We all hate them, yet there’s no way around them .. sometimes. Well, actually sometimes they can be even useful. What if you are programming a web 2.0 site and want to create some neat popups that explain how this or that works? Popups can also come in handy if you want to make sure that visitors to your blog don’t miss any important information.
Anyway, after looking around I found two solutions. From now on, I’ll always differentiate between the “Blogger solution” and the “Marketeer solution”. If you don’t know why I am doing that, I suggest you subscribe to our mailing list and grab your free eBook.
Popup Script in Javascript for Bloggers
The following script is intended for bloggers. This is *not* a popup that will automatically popup, although you could probably modify the code so it does, but it is a neat plugin that helps you to open a windows “on click”.
A link would look like this:
<a onclick="superPopup({url:this.href, type: 'someGroup'}); return false;" href="popup_window_url.html">link text</a>
Eric “Webstar”‘s Superpopup: http://www.ericwebster.net/
Popup Script in Javascript for Marketeers
Looking for a popup that is unblockable? Looking for a way to open up a little advertising window that can will open:
a) once per browser session
b) every site refresh
c) once every “x” minutes
If so, then you might want to look into this little script:
var nba_pop_toolbar = ( typeof nba_pop_toolbar != 'undefined' ) ? nba_pop_toolbar : 0; var nba_pop_status = ( typeof nba_pop_status != 'undefined' ) ? nba_pop_status : 0; var nba_pop_menubar = ( typeof nba_pop_menubar != 'undefined' ) ? nba_pop_menubar : 0; var nba_pop_scrollbars = ( typeof nba_pop_scrollbars != 'undefined' ) ? nba_pop_scrollbars : 0; var nba_pop_resizable = ( typeof nba_pop_resizable != 'undefined' ) ? nba_pop_resizable : 1; var nba_pop_page_delay = ( typeof nba_pop_page_delay != 'undefined' ) ? nba_pop_page_delay : 1; var nba_pop_limit = ( typeof nba_pop_limit != 'undefined' ) ? nba_pop_limit : 'session'; var nba_pop_type = ( typeof nba_pop_type != 'undefined' ) ? nba_pop_type : 'over'; var nba_ie = false; var nba_popped = false; function nba_launch() { if ( ( nba_get_cookie( 'nba_pop' ) == false ) && ( nba_popped == false ) ) { nba_set_cookie( 'nba_pop', 1 ); nba_popped = true; window.open( nba_url, '', 'height=' + nba_pop_height + ',width=' + nba_pop_width + ',left=' + ( ( screen.width - nba_pop_width ) / 2 ) + ',top=' + ( ( screen.height - nba_pop_height ) / 2 ) + ',toolbar=' + nba_pop_toolbar + ',status=' + nba_pop_status + ',menubar=' + nba_pop_menubar + ',scrollbars=' + nba_pop_scrollbars + ',resizable=' + nba_pop_resizable ); if ( nba_pop_type == 'under' ) { window.focus(); window.setTimeout( 'window.focus()', 100 ); } } } var nba_url = 'http://domain.com' ; function nba_init() { if ( navigator.appVersion.indexOf( 'MSIE' ) != -1 ) { nba_ie = true; } window.setTimeout( 'nba_trigger()', ( nba_pop_page_delay * 1000 ) ); } function nba_trigger() { if ( nba_ie == true ) { document.getElementById( 'nba_field' ).fireEvent( 'onchange' ); } } function nba_set_cookie( name, value ) { var expires = ''; if ( nba_pop_limit != false ) { if ( typeof( nba_pop_limit ) == 'number' ) { var d = new Date(); d.setTime( d.getTime() + nba_pop_limit * 60 * 1000 ); expires = '; expires=' + d.toGMTString(); } document.cookie = name + '=' + escape( value ) + expires + '; path=/'; } } function nba_get_cookie( name) { var re = new RegExp( '(\;|^)[^;]*(' + name + ')\=([^;]*)(;|$)' ); var res = re.exec( document.cookie ); return res != null ? unescape( res[ 3 ] ) : false; } var nba_body = document.getElementsByTagName( 'BODY' ).item( 0 ); window.onload = nba_init; window.onclick = nba_launch; document.write( '<input id="nba_field" style="width: 0px; top: 0px; position: absolute; visibility: hidden;" />' );
Now that’s quite a long script and you will have to call it like that:
<script type="text/javascript"><!--mce:0--></script>
Uncomment whatever you need
//var nba_pop_limit = 1; //once every x minutes //var nba_pop_limit = false; //every page load var nba_pop_limit = 'session'; //once every browser session
You need to specify your URL in the first snippet, modify nba_url:
var nba_url = 'http://domain.com' ;
Like our posts? Then subscribe via Mail:










Leave your response!