You need to sign in to do that
Don't have an account?

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
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
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.
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.
Hey,
Thank you very much.
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