Write code today found that the same page multiple places need to call the same child page, if more than one method call, the same sub-page callback parent page method will be a problem, so check the information, let this function generalized, according to specific method callback specific parent page method, by the way, I hope that later can be useful, Maybe to help people in need of help.
Use the eval() function here
Definition and usage
The eval () function computes a string and executes the JavaScript code in it.
The path to the child page called by the parent page (the path to the child page) is as follows
Http://localhoust:8080/oss-portlet/html/util/area.html?oid=4&name= Test &callback=callbackdistrict
callback: parameter is the specific method name of the parent page
The child page calls the parent page of the callback specified method
eval (' Window.opener ' + getparams ("callBack") + ' (\ ' + ids + ' \ ', \ ' + names + ') ');
Window.close ();
/**
* Get page Path parameter values
*/
function Getparams (key) {
var href = window.document.location.href;
if (Href.indexof ("?")! =-1) {
var paramstr = href.substring (Href.indexof ("?") + 1, href.length);
if (Paramstr.indexof (key + "=")! =-1) {
Paramstr = paramstr.substring (paramstr.indexof (key + "="),
Paramstr.length);
if (Paramstr.indexof ("&")! =-1) {
Return paramstr.substring (paramstr.indexof ("=") + 1, paramstr
. IndexOf ("&"));
} else {
Return paramstr.substring (paramstr.indexof ("=") + 1,
Paramstr.length);
}
} else {
Return "";
}
}
}
When the JS parent page invokes the child page data, the child page passes through the parent page The parameter callback the parent page concrete method