Wojciech Szabowicz
Wojciech Szabowicz

Reputation: 4198

Block browser tabs using jquery

Is there a way to block browser tabs using jquery? or atleast is there a way to create a script that will work in all browser tab at once. Deal is I have a form that can be send multiple times and that's is right thing, and he can be opened in multiple tabs in my browser. I want to create some sort of blockade that will stop moving to other tabs or submitting other forms until one is done sending, and it seems I cant find a way to do it.

Upvotes: 1

Views: 990

Answers (1)

Hiren Kagrana
Hiren Kagrana

Reputation: 932

Try HTML5 Local Storage:

    $(function () {
        var formLoadCount = parseInt(localStorage.getItem("FormLoadCount") || 0);
        if (formLoadCount == 0) {
            alert("form is successfully loaded");
        }
        else {
            alert("form is already loaded in another tab");
        }
        formLoadCount = parseInt(formLoadCount) + 1;
        localStorage.setItem("FormLoadCount", formLoadCount);

        $(window).unload(function () {
            formLoadCount = formLoadCount - 1;
            localStorage.setItem("FormLoadCount", formLoadCount);
        });
    });

Upvotes: 2

Related Questions