Home  >  Article  >  Web Front-end  >  Find a element application case through url_javascript skills

Find a element application case through url_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:50:441070browse

An example of a previous project: when adding students, there was no class data. Need to automatically jump to the class display page.

Problem: The student, class and other data are placed in jsp inside the iframe. The button for student management is in the menu bar on main.html.

mian page menu

Class management:

Student management:

The jsp in the iframe keeps changing.

Solution:

In the student management jsp, find the class management tag of the parent form by id, and click

Copy code The code 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 through the url and click.
Copy code The code is as follows:

What you want to get is the changeContent('url parameter') of the onClick method

Look at the code directly:
Copy the code The code 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 the url
var start = str.indexOf (' classManager/classList.do');
if(start>0){
$(domEle).click();
}
});

Summary : I used to use jquery to find a way to get the onclick attribute. I used indexOf to always report an error. Just add "" and convert the spaces into strings
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn