1

I have a button in salesforce when clicked opens a visualforce page. And when the button is clicked twice it opens two windows of visualforce pages. I want the window to be opened only once. If the window is already open, i need to show an alert popup like 'window is already open' and may be focus it. So is there any way to check if the visualforce page is already open.

The button is present on another page too which opens the same visualforce page. So disabling the button on first click will work only for the button on same page

  • Using the target property of the window.open will cause subsequent attempts to open it in the previously opened window – Eric Feb 25 at 5:21
0

You can disable the button when it is clicked first time and window is opened, the enable the button again on close event of window.

0

Try this code :

<script type="text/javascript">
  function openpopup(){

    var windowOpened = false;
    if(windowOpened == true)
        alert('A');
    else{
        var KontenWindow = window.open('','Konten','height=200,width=385,status=yes,scrollbars=yes,resizable=yes');
        windowOpened = true;
    }
    //setTimeout("openpopup()",100);

    KontenWindow.focus();

  }
 </script>




<input type="button" value="Click" onclick="javascript:openpopup();" class="btn" />
  • yes, getting window reference by its name, already tried that. VF page throwing empty error at window.open line – Shawn Apr 1 '15 at 5:19
  • can you post some snippet of your code – Poonam Apr 1 '15 at 5:21

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.