You need to sign in to do that
Don't have an account?
Arup Sarkar
Opening a popup window in visualforce
Hi:
I am using the following in my visualforce page to open a new window but it is opening in the same window, can anyone please tell me how to open a popup window ?
<script type="text/javascript"> function popupwindow(){ var newwindow = window.open('/apex/CallReportDataComponentPage','Call Report'); newwindow.focus(); } </script> <apex:commandButton action="{!InvokeCallReport}" value="Generate Report" onclick="popupwindow"/>
I have always used this when I wanted to have a pop up window:
window.open('URL',
'Popup','height=400,width=1000,left=100,top=100,scrollbars=yes,toolbar=no,status=no');
I put it in the onclick="" .
Given that you are using a commandbutton, you may also want to return false from the onclick handler, otherwise the form submission will continue.
Thanks everyone for replying, it is still not working it is still opening in the same window. I will depict the sequence of action followed.
step 1:
User enters parameters in "CallReportsSummaryPage", which has button, which is eventually mapped to a Apex Class. below is my modified code of the VF page.
step 2:
The InvokeCallReport() PageReference function gets invoked in the Apex class, please see the code below.
step 3:
CallReportDataComponentPage is mapped to getCallReportData() in the apex class, see code below.
Clarification:
In my popupwindow function I do have sCallReportIdParam in my window.open function.
You can use target="_parent" property to open a pop up window in a parent window. Try out window.open(url,target="_parent");
try the target _blank like following :-
If you want some sample code, here's a blog post that mimics a Salesforce lookup in Visualforce, including opening a popup window:
http://bobbuzzard.blogspot.com/2010/09/visualforce-lookup.html
Hope this will help you opeing popup in new window.
<script type="text/javascript">
function OpenPreviewPopUp()
{
var w = window.open('/apex/CallReportDataComponentPage',"MsgWindow", target='_blank')
return w;
}
</script>
Thanks,
SAKTI