An improved version of JavaScript with different page values _javascript skills

Source: Internet
Author: User
In fact, the principle is very simple. Also first, the Type property is GetAttribute, and the button is captured. Then, when the button is onclick, I pass through the URL to the child page.
Copy Code code as follows:

<input type= "text"/><input type= "Submit"/>
<input type= "text"/><input type= "Submit"/>

<script type= "Text/javascript" ><!--
var ainput = document.getelementsbytagname ("input");
for (i = 0; i < ainput.length; i++)
{
(
function (i) {
if (Ainput[i].getattribute ("type") = = "Submit")
{
Ainput[i].onclick = function () {
window.open (' b.html? ') +i, ' NewWindow ', ' height=100,width=400 ')
}
}
}
) (i)
}
--></script>

Sub-pages use the slice method to slice URLs. and use the Window.opener method to capture the text box of the parent page and assign the value. Everything's OK.
Copy Code code as follows:

<input type= "text"/><input type= "Submit"/>

<script type= "Text/javascript" ><!--
var ainput = document.getelementsbytagname ("input");

for (i = 0; i < ainput.length; i++)
{
if (Ainput[i].getattribute ("type") = = "Text") var textboxb = new Object (ainput[i));
if (Ainput[i].getattribute ("type") = = "Submit") var BTNB = new Object (ainput[i));
}

Btnb.onclick = function () {
var stextvalue = Textboxb.value
var ainput = window.opener.document.getElementsByTagName ("input");
var surl = document.location;
var sNo = surl.tostring (). Slice (-1)
window.opener.ainput[sno-"1"].value = Stextvalue
Window.close ();
}
--></script>

A friend who doesn't get it, just look at the schematics.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.