Home >Web Front-end >JS Tutorial >Example of js subpage getting parent page data_javascript skills

Example of js subpage getting parent page data_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:48:101466browse

When doing page preview, the data is not stored in the database, but a page needs to be opened for preview. I asked the aunts and found out that this is how it is done.

1. Parent page

Copy code The code is as follows:

< input type="text" id="name" value="zhangsan"/>
Preview

2. The subpage, that is, a.html gets the value of the text box in the parent page
Copy the code The code is as follows :

$(function(){

console.info(window.opener.document.getElementById("name").value);
});

In this way, what comes out in the console is the value of the text box on the parent page

Don't hurry say have no choice, perhaps, next intersection will meet hope.
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