Give an example of a previous project: When you add a student, there is no class data. Need to automatically jump to the class display page.
Question: Students, classes and other data is placed in the IFRAME inside the JSP. The student-managed button is on the Main.html menu bar.
Workaround:
Find the parent form's class management <a> tags by ID and click
Copy Code code as follows:
$ (window.parent.document). Find ("#folder_12"). Click ();
Later, the menu bar changed to dynamic, menu ID is also the dynamic of nature.
Want is to get <a> by URL, and click.
Copy Code code as follows:
<a id= "folder_14" onclick= "removetopmenucss (); Switchfolder (this.id); Changecontent (' Classmanager/classlist.do ' , this); "onfocus=" This.blur () "href=" javascript:void (0); "target=" MainFrame "> Class management </a>
To get is the changecontent (' url parameter ') of the OnClick method
Look directly at the code:
Copy Code code 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 onclick property value, search URL
var start = Str.indexof (' classmanager/classlist.do ');
if (start>0) {
$ (Domele). Click ();
}
});
Summary: The original has been using jquery to find ways to get the OnClick property, with indexof total error, plus "" space into string on the line