• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 72
  • Last Modified:

Redirect on Javascript window close

I have a script that is popping a window (uglipop) from vb code

ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "script", "$(document).ready(function () { custom1(); });", True)

On close of that window how do I reload the current page?
0
Larry Brister
Asked:
Larry Brister
1 Solution
 
Ryan ChongCommented:
I believe this is linked to your previous question.

you got to download a copy of https://cdn.jsdelivr.net/npm/uglipop@1.0.0/uglipop.js
and place it in your local drive, like:

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

Open in new window


and then edit the function remove() in case you need to add your custom function after that.

js/uglipop.js:
function remove() {
        doc.getElementById('uglipop_overlay_wrapper').style.display = 'none';
        doc.getElementById('uglipop_overlay').style.display = 'none';
        doc.getElementById('uglipop_content_fixed').style.display = 'none';

        yourFunction();
    }

    function yourFunction() {
        alert("Page will be refreshed");
        location.reload();
    }

Open in new window

0
 
Larry Bristersr. DeveloperAuthor Commented:
Hey ryan,
 That put me on the right track.

But it was only after I added the additional function on the page that it worked.      
(document.getElementById('closeButton').addEventListener('click', function (e) {.... )

 <script type="text/javascript">
            var dStatString = document.getElementById('<%= PaymentStatusFlag.ClientID%>').value;
            var custom1 = function () {
                uglipop({
                    class: 'put', //styling class for Modal
                    source: 'html',
                    content: '<div class="upop"><br /><br /><br />' + dStatString + '<div id="footer"><button id="closeButton">Close</button></div></div>'
                });

                document.getElementById('closeButton').addEventListener('click', function (e) {
                    var res = window.location.href;
                    var uri = res.replace("%2f", "/");
                    var lastslashindex = uri.lastIndexOf('/');
                    var result = uri.substring(lastslashindex + 1);
                    var foo = 'GlobalPaymentsSMSPayment4.aspx?/' + result;
                    // var foo = 'http://membersv4.everyware.com/GlobalPaymentsSMSTextLandingALT.aspx?/' + result;
                    //alert(foo);
                    setTimeout("window.location='" + foo + "'", 100);
                }, false);
            }
        </script>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now