1

I have one sharepoint requirement of closing the browser or tab in google chrome after user click on submit button .Already tried window.close(); ,its not working in current version browsers (only working in IE) .So pls help with the code using jquery or javascript . Small code which i'm trying -

$(document).ready(function(){
            $("#btn").click(function () {   //btn -button id

            var e = $.Event();
            e.which == 87; //W keycode
            e.ctrlKey == true;
            $(this).trigger('e');

            alert(1);
        });
        });
  • Did you try with window.top.close(); ? – Kaushal15 Nov 30 '16 at 10:08
  • yes..it doesn't work in browser new versions..tried this also window.open("", "_self")..but no good . – Jaspreet Singh Dec 1 '16 at 5:15
  • If you can't activate ctrl+W you can try creating the tab through your own JS. This will allow you to then close it (JS only allows you to close the tabs you make programmatically). – Roland Dec 1 '16 at 5:22
1

Try adding javascript function to create a tab or window.open() or anything that will programmatically open a new tab when user click on the button / link that refer to your form / page.

Then on that form / page, after user click submit button, you should be able to close the page using window.close() (since javascript only allows you to close a tab / window that you open programmatically).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.