function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
YashavantYashavant 

New Popup window in Current Visualforce page

Hi,

I want to open new popup window in current visualforce page and retrieve some data from custom object and display on that new popup window. After user interruption , i want to store the result back to custom object.

Can anybody provide me pointers on this?


Thank you very much in advance.


Yash
MPIMPI
Should be able to pull everything off with Javascript. Use Javascript's window.open(), then in the window that you open you should be able to pass any "default" information to populate that window using GET variables, or if it's tricker than that I think you may be able to use the DOM to fill it in directly after the window opens. Then upon clicking on the button you use DOM referencing the parent (window) to fill in whatever you received as input.

You can refer to any Salesforce input field but assigning them a javascript/DOM id using the id="..." parameter.

Also, you may be better off with a DIV that appears rather than a new window. Might make the process of referring to it easier.
YashavantYashavant
Thanks for immediate response. Can you give me an example of this? It will be very helpful for me.

Yash
hisrinuhisrinu

Are you looking for this one?

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=7075
YashavantYashavant
Hi,

I am facing problem in following code.
Code:
<apex:page >
  <html>
  <head>
  <script type="text/javascript">
      function openpopup(){
        alert('A');
        
        var KontenWindow = window.open('','Konten','height=200,width=385,status=yes,scrollbars=yes,resizable=yes');

        //setTimeout("openpopup()",100);

        KontenWindow.focus();
        
      }
  </script>
  </head>
<body>
<h1>Popup Window</h1>

<input type="button" value="Click" onclick="javascript:openpopup();" class="btn" />

</body>
</html>

</apex:page>

 
The javascript function openpopup() is not calling.

Can anybody suggest me the solution for this?


Yash

MPIMPI
Yashavant,

When using an input button in HTML, there is no need to add the javascript: prefix to the onClick="...". A javascript: prefix is only necessary when calling javascript from an "a href=" tag.

https://developer.mozilla.org/En/DOM/Window.open

Provides a very reasonable set of instructions on how to open a new window as well as a section on Best Practices with a complete example.

As far as the rest of the logic you wish to implement, without a full Javascript tutorial on using the DOM (Document Object Model) to change HTML on the fly I wouldn't be able to do much for you but this tutorial seems to fit what you're doing:

http://www.rgagnon.com/jsdetails/js-0066.html
YashavantYashavant
Hi,
I can able to call the popup window and also able to set the values to popup window object.
Now onclick on popup window buttion , i want to set the child window values to parent window.

Code:
<apex:page >

<HTML><HEAD></HEAD>
<SCRIPT LANGUAGE="JavaScript">
    function openChild(file,window) {
        childWindow=open('','','resizable=yes,width=600,height=600');
        if (childWindow.opener == null){ 
            childWindow.opener = self;
        }else{
            childWindow.document.write('<FORM NAME="childForm"  >');
            childWindow.document.write('<BR>To      :<INPUT NAME="cf1To" TYPE="TEXT" VALUE="" size="60">');
            childWindow.document.write('<BR>CC      :<INPUT NAME="cf2Cc" TYPE="TEXT" VALUE="" size="60">');
            childWindow.document.write('<BR>Subject :<INPUT NAME="cf3Subject" TYPE="TEXT" VALUE="" size="60">');
            //childWindow.document.write('<BR>Body :<textarea rows="2" cols="20"/>');
            childWindow.document.write('<BR><INPUT TYPE="button" VALUE="Submit" onClick="return updateParent();">');
            childWindow.document.write('</FORM>');
            childWindow.document.childForm.cf1To.value='yashavant_bhalekar@persistent.co.in';
            childWindow.document.childForm.cf2Cc.value='manjiri_yatnalkar@persistent.co.in';
            childWindow.document.childForm.cf3Subject.value='Confirmation';
        }
     }
</SCRIPT>

<BODY>
<FORM NAME="parentForm">
<INPUT TYPE="button" VALUE="Open child" 
  onClick="openChild('examplejs2.html','win2')">
<BR><INPUT NAME="pf1" TYPE="TEXT" VALUE="">
<BR><INPUT NAME="pf2" TYPE="TEXT" VALUE="">
</FORM>
</BODY></HTML>
</apex:page>

When i try to add the javascript function in the child window , it is giving me error.
Code is as follow.

Code:
<apex:page >

<HTML><HEAD></HEAD>
<SCRIPT LANGUAGE="JavaScript">
    function openChild(file,window) {
        childWindow=open('','','resizable=yes,width=600,height=600');
        if (childWindow.opener == null){ 
            childWindow.opener = self;
        }else{
            childWindow.document.write('<SCRIPT LANGUAGE="JavaScript">');
     childWindow.document.write('function updateParent() {');
     childWindow.document.write('opener.document.parentForm.pf1.value = document.childForm.cf1.value;');
     childWindow.document.write('opener.document.parentForm.pf2.value = document.childForm.cf2.value;');
     childWindow.document.write('self.close();return false;}');
            childWindow.document.write('</SCRIPT>'); 
            childWindow.document.write('<FORM NAME="childForm"  >');
            childWindow.document.write('<BR>To      :<INPUT NAME="cf1To" TYPE="TEXT" VALUE="" size="60">');
            childWindow.document.write('<BR>CC      :<INPUT NAME="cf2Cc" TYPE="TEXT" VALUE="" size="60">');
            childWindow.document.write('<BR>Subject :<INPUT NAME="cf3Subject" TYPE="TEXT" VALUE="" size="60">');
            //childWindow.document.write('<BR>Body :<textarea rows="2" cols="20"/>');
            childWindow.document.write('<BR><INPUT TYPE="button" VALUE="Submit" onClick="return updateParent();">');
            childWindow.document.write('</FORM>');
            childWindow.document.childForm.cf1To.value='yashavant_bhalekar@persistent.co.in';
            childWindow.document.childForm.cf2Cc.value='manjiri_yatnalkar@persistent.co.in';
            childWindow.document.childForm.cf3Subject.value='Confirmation';
        }
     }
</SCRIPT>

<BODY>
<FORM NAME="parentForm">
<INPUT TYPE="button" VALUE="Open child" 
  onClick="openChild('examplejs2.html','win2')">
<BR><INPUT NAME="pf1" TYPE="TEXT" VALUE="">
<BR><INPUT NAME="pf2" TYPE="TEXT" VALUE="">
</FORM>
</BODY></HTML>
</apex:page>

Any pointer on this will be helpful.

Yash

 
MukulMukul

Hi Yashawant,

 

I am trying to do something very similar. Were you able to do this?

 

Can you give some pointers to me?

 

Regards

Mukul

Arijit.MajeeArijit.Majee

the input field closing was not correct.

Hope it will help.

<apex:page >

<HTML><HEAD></HEAD>
<SCRIPT LANGUAGE="JavaScript">
    function openChild(file,window) {
        childWindow=open('','','resizable=yes,width=600,he​ight=600');
        if (childWindow.opener == null){ 
            childWindow.opener = self;
        }else{
            childWindow.document.write('<FORM NAME="childForm"  >');
            childWindow.document.write('<BR>To      :<INPUT NAME="cf1To" TYPE="TEXT" VALUE="" size="60"/>');
            childWindow.document.write('<BR>CC      :<INPUT NAME="cf2Cc" TYPE="TEXT" VALUE="" size="60"/>');
            childWindow.document.write('<BR>Subject :<INPUT NAME="cf3Subject" TYPE="TEXT" VALUE="" size="60">');
            //childWindow.document.write('<BR>Body :<textarea rows="2" cols="20"/>');
            childWindow.document.write('<BR><INPUT TYPE="button" VALUE="Submit" onClick="return updateParent();">');
            childWindow.document.write('</FORM>');
            childWindow.document.childForm.cf1To.value='yashav​ant_bhalekar@persistent.co.in';
            childWindow.document.childForm.cf2Cc.value='manjir​i_yatnalkar@persistent.co.in';
            childWindow.document.childForm.cf3Subject.value='C​onfirmation';
        }
     }
</SCRIPT>

<BODY>
<FORM NAME="parentForm">
<INPUT TYPE="button" VALUE="Open child" 
  onClick="openChild('examplejs2.html','win2')"/>
<BR><INPUT NAME="pf1" TYPE="TEXT" VALUE=""/></BR>
<BR><INPUT NAME="pf2" TYPE="TEXT" VALUE=""/></BR>
</FORM>
</BODY></HTML>
</apex:page>