Home >Web Front-end >HTML Tutorial >The parent page gets the content of the child page_html/css_WEB-ITnose

The parent page gets the content of the child page_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:56:191210browse

Requirement description: Two JSP pages. The parent page needs the content of the child page, but the child page is hidden. Specifically, the child page is a series of templates, and the parent page needs to obtain these templates through ID. , unwilling to import through , because if there are too many templates, the entire parent page will be too large and slow to load. I wonder if the following two solutions can solve this problem.

1, through ajax Method

Implementation process: request to the subpage through ajax, and the subpage gets the parameter id and uses the interaction of java and js variables to return the required template information

Disadvantage: convert the js variable into Java variables are more troublesome. They need to be submitted using form forms, and the java script in jsp is run on the server side, which requires server-side resource overhead and increases the number of interactions

2, introduced through iframe

Implementation process: Use iframe to introduce subpages, and then obtain the required template through $(iframe.contents().find("#" id)[0]).val().

Disadvantages: Not sure if iframe can be delayed loaded. If you want to import the entire page like , this method is not ok.

We welcome readers and netizens to put forward their own opinions and methods for improvement.

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