Phiên bản đầy đủ: jsB@nk » Trình duyệt » Cửa sổ » Tạo popup với sự kiện onLoad
URL: https://www.javascriptbank.com/opens-2-popup-onload.html
Nếu đặt đoạn mã JavaScript JavaScript này vào trang web thì sẽ có hai cửa sổ mới tự động mở ra khi có người truy cập vào trang.
Phiên bản đầy đủ: jsB@nk » Trình duyệt » Cửa sổ » Tạo popup với sự kiện onLoad
URL: https://www.javascriptbank.com/opens-2-popup-onload.html
<SCRIPT language=Javascript>function big_init(){self.y_center=(parseInt(screen.height/2));self.x_center=(parseInt(screen.width/2));self.pop_stack=Array();}function get_center(size, side){center = eval('self.'+side+'_center-('+size+'/2);');return(parseInt(center));}function close_pop(pop_name){eval ('pop_'+pop_name+'.close()');}function build_pop(url, pop_name, pop_width, pop_height, pop_left, pop_top, pop_status, pop_resizable, pop_directories, pop_toolbar, pop_scrollbars, pop_reload){if (typeof(pop_width) == 'string'){pop_width=parseInt((pop_width.substr(0, pop_width.indexOf('P')-1))*(screen.width/10));} if (pop_width<100) { alert('ancho invalido: '+pop_width); pop_width=100; }if (typeof(pop_height) == 'string'){ pop_height=parseInt((pop_height.substr(0, pop_height.indexOf('P')-1))*(screen.height/10)); }if (pop_height<100) { alert('alto invalido: '+pop_height); pop_height=100; }if (!pop_left){ pop_left=get_center(pop_width,'x');}if (!pop_top){ pop_top=get_center(pop_height,'y'); }window_opts = 'width='+pop_width+',height='+pop_height+',left='+pop_left+',top='+pop_top;if (pop_status!=1) { window_opts+= ',status=no'; } else { window_opts+= ',status=yes'; }if (pop_resizable!=1) { window_opts+= ',resizable=no'; } else { window_opts+= ',resizable=yes';}if (pop_directories!=1) { window_opts+= ',directories=no'; } else { window_opts+= ',directories=yes'; }if (pop_toolbar!=1) { window_opts+= ',toolbar=no'; } else { window_opts+= ',toolbar=yes'; }if (pop_scrollbars==0) {window_opts+= ',scrollbars=no';} else if (pop_scrollbars==1) {window_opts+= ',scrollbars=yes';} else {window_opts+= ',scrollbars=auto';} eval('self.pop_it=1;\n'+ 'if (self.pop_'+pop_name+' && !pop_'+pop_name+'.closed) {\n'+'self.pop_it=0;\n'+'if (pop_reload){\n'+'if (pop_reload==\'R\') {\n'+'pop_'+pop_name+'.reload();\n'+'} else if(pop_reload==\'C\') {\n'+'pop_'+pop_name+'.close();\n'+'self.pop_it=1;\n'+'} else {\n'+'pop_'+pop_name+'.location="'+url+'";\n'+'}\n'+'}\n'+'}'+'if (self.pop_it==1) {\n'+'pop_'+pop_name+' = window.open ("'+url+'", "pop_'+pop_name+'", "'+window_opts+'");\n'+'var set_stack=true;\n'+'}\n'+'pop_'+pop_name+'.focus();');// Obviously i have to finish this next part of the script, but i really don't have time...if (set_stack || (pop_reload && (pop_reload!='R' || pop_reload!='C'))){self.pop_stack[pop_name]=new Array();self.pop_stack[pop_name]["url"]=url;self.pop_stack[pop_name]["pop_width"]=pop_widthself.pop_stack[pop_name]["pop_height"]=pop_heightself.pop_stack[pop_name]["pop_left"]=pop_leftself.pop_stack[pop_name]["pop_top"]=pop_topself.pop_stack[pop_name]["pop_status"]=pop_statusself.pop_stack[pop_name]["pop_resizable"]=pop_resizableself.pop_stack[pop_name]["pop_directories"]=pop_directoriesself.pop_stack[pop_name]["pop_toolbar"]=pop_toolbarself.pop_stack[pop_name]["pop_scrollbars"]=pop_scrollbars// FINISHTHIS!!! (si es que es verdaderamente necesario... :-)// pop_stack[name]["maximized"]=1 ?? necesito ??//for (x=0; x<=pop_stack.length; x++) { msg=pop_stack[x]+'\n'; }//alert(msg);// alert(pop_stack[pop_name]["url"]);}}</SCRIPT><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<BODY onload="big_init();"><SCRIPT>build_pop("popup_content.html", "example1", '50P', '50P', '320', '220', '1', '1', '1', '1', '1', '1');</SCRIPT><SCRIPT>build_pop("popup_content.html", "example2", '25P', '70P', '10', '10', '1', '1', '1', '1', '1', '1');</SCRIPT></BODY><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->