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
downloadingdownloading 

New Window

Hi,

  Could any one help me with the apex code ,where a new window has to be opened,

   i have already tried with window.open but that's not working properly , please help 

   me how would i achieve this.

 

  Thank you

pbattissonpbattisson

Hi

 

It isn't possible to do this in apex. Apex is the Object-orinetated Java like language used for developing controllers, triggers an classes that run on the Force.com platform.

 

What you need to do is change your command button on your Visualforce page to have an onClick event that calls the javascript window.open command.

 

Paul

Navatar_DbSupNavatar_DbSup

Hi,
You can do this through javascript.Try the below code as reference:
/////////////////////// VF Pages ////////////////////////////////
<apex:page sidebar="false" standardStylesheets="false" controller="LinkController">

<apex:outputPanel styleClass="app-icon" layout="block" id="app">
<apex:form >
<apex:commandLink action="{!Save}" reRender="app" value="rediff" onclick="WindowNew()">
<script>
function WindowNew()
{
alert('abc');
window.open('http://www.rediff.com/');
}
</script>
</apex:commandLink>
</apex:form>
</apex:outputPanel>

</apex:page>
/////////////// Controller /////////////////////////
public class LinkController {

public PageReference Save()

{

String newPageUrl = 'http://www.rediff.com/';

return null;

}
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

downloadingdownloading

Hi,

The new window is opened in a new Tab,

i have already tried with a similar approach.But what i am looking for is the new window has to be opened as if its a popup

which also has a title bar and address bar, similar to browser popup

pbattissonpbattisson

The tab/window thing is a preference set by the user in the browser. You shouldn't override it.

 

Ifyou really must (I would reiterate thinking hard about it first) then do:

window.open('http://www.google.com','_blank','toolbar=0,location=0,menubar=0');