Give an example of a previous project: when adding students, there is no class data. It needs to automatically jump to the class display page.
Question: Students, class and other data are placed in the jsp in the iframe. The student management button is in the menu bar on main.html.
Solution:
Search the class management <a> tag of the parent form by id and click
The code copy is as follows:
$(window.parent.document).find("#folder_12").click();
Later, the menu bar was changed to dynamic, and the menu id was naturally dynamic.
What you want is to get <a> through url and click.
The code copy is as follows:
<a id="folder_14" onClick="removeTopMenuCss();switchFolder(this.id);changeContent('classManager/classList.do',this);" onFocus="t his.blur()" href="javascript:void (0);" target="mainFrame">Class Management</a>
What you want to get is the changeContent('url parameter') of the onClick method
Look directly at the code:
The code copy is as follows:
//console.info( $(window.parent.document).find("a") );
$(window.parent.document).find("#OutFolder a").each(function (index, domEle) {
//var s = $(domEle).attr("onclick")+"";
//var start = s.indexOf (''classManager/classList.do');
var str = domEle.attributes.onclick.value;//Use js to get the onclick attribute value and search for url
var start = str.indexOf (''classManager/classList.do');
if(start>0){
$(domEle).click();
}
});
Summary: It turns out that you have been using jquery to find methods, get the onclick attribute, use indexOf to report an error, add "" space to convert it into string