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
PrattyPratty 

How can I call visualforce page through javascript ?

Hi,

 

I have to call visualforce page through javascript code. Can anybody help me to solve this problem?

 

thanks in advance.

 

Regards,

 

Pratty

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

You can use the below code

<apex:page standardController="account" >

<script>

  function printalert()

  {

  alert('hello');

  window.open('/apex/searchcontact');

  }

  </script>

  <apex:form >

 

  <apex:commandButton value="click me" onclick="printalert()"/>

 

  </apex:form>

</apex:page>

 

searchcontact(Red mark) change this with your Vf page API Name.

 

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

 


All Answers

Navatar_DbSupNavatar_DbSup

Hi,

You can use the below code

<apex:page standardController="account" >

<script>

  function printalert()

  {

  alert('hello');

  window.open('/apex/searchcontact');

  }

  </script>

  <apex:form >

 

  <apex:commandButton value="click me" onclick="printalert()"/>

 

  </apex:form>

</apex:page>

 

searchcontact(Red mark) change this with your Vf page API Name.

 

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

 


This was selected as the best answer
Chamil MadusankaChamil Madusanka

Here are some example for javascript plus visualfroce

 

http://www.salesforceworld.blogspot.com/2011/06/javascript-with-visualforce-pages.html

 

http://www.salesforceworld.blogspot.com/2011/06/parameter-passing-using.html

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

PrattyPratty

Hey, 

 

Thank you very much.

Nav_GupNav_Gup
Hello Navatar_DbSup

Thanks for your valuable reply, 

If I am using your solution then I am able to procde, but If I am using same VF page in anp Pagelayout, than I am not able to open a Vf page through a Button. In this case (Under pageLayou) when I am clicking on a button, (a nw popup or window or tab whatever is set on a javascript) URL becoms like: https://instanceofORG//servlet/AddMultipleRelatedProductsBMD


Have you any solution