Home  >  Article  >  Web Front-end  >  How to pass the object array of one page to another page, without background, save js_html/css_WEB-ITnose

How to pass the object array of one page to another page, without background, save js_html/css_WEB-ITnose

不言
不言Original
2018-05-24 15:21:252921browse

I have two pages, no background, just implemented in HTML. For example, I have two pages
1.html and 2.html.
There is a temp array in 1.html, which stores image objects. There is a submit button in 1.html. Clicking the submit button will open the 2.html page and pass the temp array to 2.html.
How to achieve it? ? ?

Reply to discussion (solution)

Is the temp array a variable? Control the content inside through 1.html? And pass it to 2.html?

1.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><body><p id="demo"><img src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" /><img src="http://images.csdn.net/20120528/程序员6月封面_副本_副本.jpg" /></p><button onclick="window.open(&#39;2.html&#39;);">OPEN</button><script type="text/javascript">var obj = document.getElementById(&#39;demo&#39;).getElementsByTagName(&#39;img&#39;), ar = [];for (var i = 0; i < obj.length; i ++) ar.push(obj[i]);</script></body></html>

2.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><body><script type="text/javascript">var ar = window.opener.ar;alert(ar[0].src);</script></body></html>

var ar = window.opener.ar
Please explain

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