1, pop up the specified size of the page modal dialog box (using the ShowModalDialog () method is not compatible with chrome)
function OpenDialog () {
var somevalue = window.showModalDialog ("news.html", "", "DIALOGWIDTH=640PX;DIALOGHEIGHT=423PX;STATUS=NO;HELP=NO; Scrollbars=no ")
}
Description: ShowModalDialog (surl,vargument,sfeatures)
sURL: Specify the URL address;
Varguments: Passes parameters to the Web Page dialog box, with no restriction on the type of pass parameters.
Sfeatures: Optional, set parameters for dialog box.
Setting parameters for the dialog box:
2. Pop-up Page Mode dialog box with full screen display
function OpenDialog () {
var width = screen.width;
var height = screen.height;
window.showModalDialog ("news.html", "", "dialogwidth= ' +width+ ' px;dialogheight= ' +height+ ' px;status=no;help=no; Scrollbars=no ");
}
Description: The ShowModalDialog () method opens a Web Page dialog box that is modal, placed above the parent window, must be closed before the parent window can be accessed, and showModelessDialog () opens a modeless window that opens without having to close and access the parent window. (showModelessDialog not compatible with Firefox and Chrome)
3. Web Color Picker
Color window:
var h = new Array (6)
H[0] = "FF";
H[1] = "CC";
H[2] = "99";
H[3] = "66";
H[4] = "33";
H[5] = "00";
function Action (RGB) {
Alert (' The color you selected is: # ' +rgb);
Parent.window.returnvalue= "#" +RGB;
Window.close ();
}
function Mcell (R, G, B) {
document.write (' <td bgcolor= ' # ' + R + G + B + ' "> ');
document.write (' <a href= ' # "onclick=" action (\ ' + (R + G + B) + ' \ ') ' > ');
document.write (' ');
document.write (' </a> ');
document.write (' </td> ');
}
function Mtr (R, B) {
document.write (' <tr> ');
for (var i = 0; i < 6; ++i) {
Mcell (R, H[i], B);
}
document.write (' </tr> ')
}
function Mtable (B) {
document.write (' <table cellpadding=0 cellspacing=0 border=0> ');
for (var i = 0; i < 6; ++i) {
MTR (H[i], B);
}
document.write (' </table> ');
}
function Mcube () {
document.write (' <table cellpadding=0 cellspacing=0 border=0><tr> '); //
for (var i = 0; i < 6; ++i) {
if (i%3==0) {
document.write (' <tr> ');
}
document.write (' <td bgcolor= ' #FFFFFF > ');
Mtable (H[i])
document.write (' </td> ');
}
if (i%3==0) {
document.write (' </tr> ');
}
document.write (' </tr></table> ');
}
Mcube ()
Main window:
function Colorpick (field) {
var Rtn = window.showModalDialog ("color.htm", "" "," dialogwidth:225px;dialogheight:170px;status:no;help:no;scrolling =no;scrollbars=no ");
if (rtn!=null)
Field.style.background=rtn;
Return
}
Call Function:
<input name= "Color" type= "text" id= "Color" size= "3" readonly= "yes" style= "background: #000;" onclick= "Colorpick ( this); " >
JS Sample Learning--window/frame and navigation bar Design popup Page dialog box