Home >Web Front-end >HTML Tutorial >When the js parent page calls the child page data, the child page calls back the parent page through the parameters passed by the parent page. Specific method_html/css_WEB-ITnose
When I was writing code today, I found that multiple places on the same page need to call the same subpage. If multiple methods are called, the same subpage will call back the parent page method, which will cause problems, so I checked the information and let this function General, call back the specific parent page method according to the specific method. By the way, to summarize, I hope it will be useful in the future, maybe it can help people who need help
Use here eval() function
eval() function can calculate a string and execute it JavaScript code.
The path of the parent page calling the child page (the path of the child page) is as follows
http://localhoust:8080/oss -portlet/html/util/area.html?oid=4&name=test&callBack=callBackDistrict
callback: The parameter is the specific method name of the parent page
The child page calls the method specified by the callback of the parent page
. '','' names '')');
function getParams(key) {
var href = window.document.location.href;
var paramStr = href. substring(href.indexOf("?") 1, href.length);
Key "="),
if (Paramstr.Indexof ("&")! = -1) {
Return Paramstr.substring (paramstr.indexof ("=") 1 , paramStr
.indexOf("&"));
. } else {
. paramStr.length);
} else {
return "";