Parse JS to get the parent window link GetParent method and various open window method _ basic knowledge

Source: Internet
Author: User

Copy Code code as follows:

//Open modal window
Function dialog (obj) {
if (Obj.url = = Undefined | | obj.url = NULL) {
throw new Error ("Please set Obj.url");
}
var url = obj.url;
if (Url.indexof ("?")! =-1) {
url = url+ "&r_=" + math.random ();
}else {
url = url+ "? r_=" + math.random ();
}
Alert (Obj.width + "," + Obj.height + "," + Obj.top + "," + obj.left);
var W;
if (!obj.width) {
W = SCREEN.WIDTH/2;
}else{
W = parseint (obj.width);
}
var h;
if (!obj.height) {
h = 500;
}else{
h = parseint (obj.height);
}
var T;
if (!obj.top) {
t = 50;
}else{
t = parseint (obj.top);
}
var L;
if (!obj.left) {
L = (Screen.width-parseint (w))/2;
}else{
L = parseint (obj.left);
}
W = parseint (w) + "px";
h = parseint (h) + "px";
L = parseint (L) + "px";
t = parseint (t) + "px";
var paramstr = "";
Paramstr + + ("dialogheight=" + H + ";");
Paramstr + = ("dialogwidth=" + W + ";");
if (obj.center!= undefined && obj.center!= null) {
Paramstr + + "center=" + Obj.center + ";"
}else{
Paramstr + = ("dialogtop=" + t + ";");
Paramstr + + ("dialogleft=" + L + ";");
}
Paramstr + = "Resizable=yes;scroll=yes";
alert (PARAMSTR);
var rv = window.showModalDialog (URL,WINDOW,PARAMSTR);
if (rv = = undefined) {
RV = Window.returnvalue;
}
if (OBJ.CB) {
Return Obj.cb.call (RV,RV);
}
return RV;
}
function Openwin (u,w,h) {
var obj = {
Url:u,
Width:w,
Height:h
}
Return dialog (obj);
}
function Openwinwithcallback (u,w,h,fun) {
var obj = {
Url:u,
Width:w,
Height:h,
Cb:fun
}
Return dialog (obj);
}
function Openwindow (obj) {
if (Obj.url = = Undefined | | obj.url = NULL) {
throw new Error ("Please set Obj.url");
}
var url = obj.url;
if (Url.indexof ("?")! =-1) {
url = url+ "&r_=" + math.random ();
}else {
url = url+ "? r_=" + math.random ();
}
Alert (Obj.width + "," + Obj.height + "," + Obj.top + "," + obj.left);
var W;
if (!obj.width) {
W = SCREEN.WIDTH/2;
}else{
W = parseint (obj.width);
}
var h;
if (!obj.height) {
h = 500;
}else{
h = parseint (obj.height);
}
var T;
if (!obj.top) {
t = 50;
}else{
t = parseint (obj.top);
}
var L;
if (!obj.left) {
L = (Screen.width-parseint (w))/2;
}else{
L = parseint (obj.left);
}
W = parseint (w);
h = parseint (h);
L = parseint (l);
t = parseint (t);

//Window handle
var name;
if (!obj.name) {
name = ' Win_ ' + new Date (). GetTime ();
} else{
name = Obj.name;
}
//alert (name);
//Can change the window size
var resizable = obj.resizable | | "No";
//whether there are scroll bars
var scrollbars= obj.scrollbars | | "Yes";
//Whether there is a status bar
var status = Obj.status | | "No";
//Whether there is a menu bar
var menubar = Obj.menubar | | "No";
//Whether there is a toolbar
var toolbar = Obj.toolbar | | "No";
//whether there is an address bar
var locations = Obj.locations | | "Yes";
Return window.open (Url,name, "height=" + H + ", width=" + w +  ", top=" + t + ", left=" + L + ", toolbar=" + toolbar ") + ", menubar=" + menubar + ", scrollbars=" + scrollbars + ", resizable=" + resizable + ", location=" + locations + ", status= "+ Status +", Hotkeys=esc ");
}

A child page of modal window open mode Gets the parent Page object
function GetParent () {
var p = "";
if (window.opener!= undefined) {
p = Window.opener;
}
else {
p = window.dialogarguments;
};
return p;
}

Child page settings for modal window open mode returnvalue
function Setreturnvalue (v) {
if (window.opener!= undefined) {
Window.opener.returnValue = v;
}
else {
Window.returnvalue = v;
};
}

//Sliding door
function Scrolldoor () {
this.value = 0;
}
Scrolldoor.prototype = {
Onlymenu:function (Menus,openclass,closeclass) {//Only menu no have content
var _this = this;
for (var i = 0; i < menus.length; i++)
{
_this.$ (Menus[i]). flag = ++this.value;
_this.$ (Menus[i]). value = i;
_this.$ (Menus[i]). onclick = function () {
for (var j = 0; J < Menus.length; J + +)
{
_this.$ (Menus[j]). ClassName = Closeclass;
_this.$ (Divs[j]). style.display = "None";
}
_this.$ (Menus[this.value]). ClassName = Openclass;
_this.$ (Divs[this.value]). style.display = "block";
}
}
},
Sd:function (Menus,divs,openclass,closeclass) {//Two class
var _this = this;
if (menus.length!= divs.length)
{
Alert ("The number of menu layers is not the same as the number of content layers!");
return false;
}
for (var i = 0; i < menus.length; i++)
{
_this.$ (Menus[i]). flag = ++this.value;
_this.$ (Menus[i]). value = i;
_this.$ (Menus[i]). onclick = function () {
for (var j = 0; J < Menus.length; J + +)
{
_this.$ (Menus[j]). ClassName = Closeclass;
_this.$ (Divs[j]). style.display = "None";
}
_this.$ (Menus[this.value]). ClassName = Openclass;
_this.$ (Divs[this.value]). style.display = "block";
}
}
},
Sd3class:function (menus,divs,openclass,closeclass,middleclass) {//three class
var _this = this;
for (var x = 0; x < Menus.length + +)
{
_this.$ (Menus[x]). State = _this.$ (Menus[x]). ClassName = = Openclass? "Open": "Close";
}
if (menus.length!= divs.length)
{
Alert ("The number of menu layers is not the same as the number of content layers!");
return false;
}
for (var i = 0; i < menus.length; i++)
{
_this.$ (Menus[i]). flag = ++this.value;
_this.$ (Menus[i]). value = i;
_this.$ (Menus[i]). onclick = function () {
for (var j = 0; J < Menus.length; J + +)
{
_this.$ (Menus[j]). ClassName = Closeclass;
_this.$ (Divs[j]). style.display = "None";
_this.$ (Menus[j]). State = ' close ';
}
This.state = "open";
_this.$ (Menus[this.value]). ClassName = Openclass;
_this.$ (Divs[this.value]). style.display = "block";
}
_this.$ (Menus[i]). onmouseover = function () {
alert (this.state);
for (var j = 0; J < Menus.length; J + +)
{
if (_this.$ (Menus[j]). State!= "open")
{
_this.$ (Menus[j]). ClassName = Closeclass;
_this.$ (Menus[j]). State = ' close ';
}
}
if (this.state = = "Open")
{
}
Else
{
This.classname = Middleclass;
}
}
_this.$ (Menus[i]). onmouseout = function () {
if (this.state!= "open")
{
This.classname = Closeclass;
}
}
}
},
$: function (OID) {
if (typeof (oid) = = "string")
return document.getElementById (OID);
Return OID;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.