Home > Technical & Creative Skills > Programming, Servers & Scripts

Popup alert script (4)


02-13-2017 09:14 AM #1 orisin1 (Member)
Popup alert script

Hey
Anyone has a popup alert script that pops a message with an OK button and a Cancel button each can be defined a URL to redirect to?


02-13-2017 10:16 AM #2 erikgyepes (Moderator)

Hey @orisin1,

I just wrote this and tested only on Desktop/Chrome, so not sure how it behaves in other browsers, but give it a try:

HTML Code:
    <script type="text/javascript">
        if (confirm('Go to Google.com?')) {
            window.location = 'http://google.com';
        }
        else {
            window.location = 'http://stmforum.com';
        }
    </script>
How it works?

When you click "OK" it redirects you to the first link, when you hit "Cancel" it redirects to the second link.

Erik


02-13-2017 11:19 AM #3 orisin1 (Member)

Tnx bud appreciate it!


02-13-2017 12:04 PM #4 erikgyepes (Moderator)

Cheers!


Home > Technical & Creative Skills > Programming, Servers & Scripts