JavaScript implementation Popup Layer (take Layer.open as an example)

Source: Internet
Author: User

First, refer to layer and download it yourself.

Add the following two lines

<script src= ". /layer/jquery.min.js "></script>

<script src= ". /layer/layer.js "></script>

Layer.open ({type:2, Skin:' Layui-layer-lan ', Title:Title, FIX:false, Shadeclose:true, Maxmin:true, area: [' 800px ', ' 400px '], content:' Default.aspx ',                //end:function () {//Turn off popup layer triggering                //location.reload (); Refreshes the parent interface and can be changed to another                //}            });

In the popup layer, how to click Submit or save, automatically close the popup layer, refresh the parent interface? Here to answer for everyone.

Suppose there are two interfaces, Default.aspx and Default2.aspx, respectively.

Set a button control in Default.aspx and hide it as follows:

<asp:button id= "Button1" runat= "Server" text= "Refresh" onclick= "Button1_Click" style= "Display:none"/>

The event content of a control Button1 can be used to save temporary data, prevent the user from filling out, not save, and refresh the interface to cause data loss.

Next is the JavaScript call to the control.

<script>
function ShowData () { document.getElementById ("Button1"). Click (); var index = parent.layer.getFrameIndex (' default2.aspx '); Parent.layer.close (index); }
</script>

Add the following code to the Submit or Save button event in the popup layer:

Scriptmanager.registerstartupscript (this "jsfun " " <script type=\ "text/javascript\" >alert (' Submit success! '); Parent. ShowData ();</script>"false";

Can be implemented, the user click Submit or save, pop-up prompt box, automatically close the pop-up layer, and refresh the parent interface.

JavaScript implementation Popup Layer (take Layer.open as an example)

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.