SoFunction
Updated on 2025-04-13

The layer pop-up layer parent-child page event calls method to each other

// Parent page

<body>

<a data-url="" >Small tip layer</a>
<input  />
<button class="but_par">Parent page</button>
</body>
<script src="../jquery-1.9."></script>
<script src="layer/"></script>
<script>
$(function(){
$("#parentIframe").click(function(){
var a = $(this).attr("data-url");
({
  type: 2,
  content: a,
  success: function(layero, index){
    var body = ('body', index);//Get subpage content    var iframeWin = window[('iframe')[0]['name']]; //Get the window object of the iframe page and execute the iframe page method: ();   ("#transmit").click();//How to execute subpage ('input').val('Hi, I came from the parent page')    $(".but_par").click(function(){
    alert(222);
    })
  }
}); 
})
})

// Subpage

<body>
<input  value="Dissatisfied" />
<button >Pass values ​​to the parent layer</button>
</div>
</body>
<script>
$(function(){
$(document).on("click","#transmit").click(function(){
parent.$("#shuzhi").val($("#name").val());
(); Refresh the parent page
//Close the layer pop-up layervar index = (); //Get window index(index);
})
.$(".but_par").click();//Execute the parent page event})
</script>

The above method of calling each other for the parent-son page events in the above layer pop-up layer is all the content I share with you. I hope you can give you a reference and I hope you can support me more.