Modify the value of the hidden input part of the parent page on the iframe page. The change event cannot be triggered ., Iframeparent
Different input components are arranged according to the type of the recharge card returned by the iframe page.
Click "select" to bring up an iframe, click the recharge card data line, and return 1. Recharge card type. 2. Recharge card id (UUID used ). 3. Recharge card number (string ).
The problem is that when iframe is set to a recharge card, the change event of the value of the input part on the parent page cannot be obtained.
Parent page js
$ ("# Id_card_type"). change (function () {// events cannot be captured });
Parent page form
<Form id = "frm" method = "post" action = "/bill/recharge/new/"> <input id = "id_card_type" name = "card_type" type = "hidden "/> <input id =" id_card_id "name =" card_id "type =" hidden "/> <label> card number </label> <input id =" id_cardno "name =" cardno "readonly =" True "type =" text "/> <span id =" btnSelectCard "> select </span> </form>
Iframe page js
$(this).children().click(function(){<span style="white-space:pre"></span>var cid=$(this).parent('tr').attr('item_id');var cn=$(this).parent('tr').children('td').eq(0).html();var ct=$(this).parent('tr').attr('item_type');$('#id_card_id', window.parent.document).val(cid);$('#id_cardno', window.parent.document).val(cn);$('#id_card_type', window.parent.document).val(ct);});
The solution is as follows:
Iframe page js
$ (This ). children (). click (function () {var cid = $ (this ). parent ('tr '). attr ('item _ id'); var cn1_0000(this%.parent('tr'%.children('td'%.eq(0%.html (); var ct = $ (this ). parent ('tr '). attr ('item _ type'); $ ('# id_card_id', specify parameter parent.doc ument ). val (cid); $ ('# id_cardno', specify parameter parent.doc ument ). val (cn); $ ('# id_card_type', specify parameter parent.doc ument ). val (ct); // $ ('# id_card_type', optional parameter parent.doc ument ). trigger ('change'); // The window is invalid. parent. $ ('# id_card_type '). trigger ('change'); // valid });
How does iframe obtain a variable value of the parent page and give this value to the input value?
Certificate (registry.parent.doc ument. body). find ("you are looking ")...
Iframe code question: can I hide the upper part of the called page by changing an attribute value?
Make the page to be nested into a frame, and hide the upper half of the frame.
No code is written.
Wish you success