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
k practicek practice 

How to get URL parameter using javascript From visualforce page?

Hi,

function newDoc() {
            window.top.location.href ='http://www.google.com/inquiry?property='+{!urlpropertyname};
            alert({!urlpropertyname});
        }

<apex:commandbutton value="getURL" onclick="newDoc();"/>

help me..
Best Answer chosen by k practice
MithunPMithunP
Hi Practice,

In your command button function you just pass required URL paramter. Below is the sample code to send parameters to javascript function
 
function newDoc(urlpropertyname) {
            window.top.location.href ='http://www.google.com/inquiry?property='+urlpropertyname;
            alert({!urlpropertyname});
        }

<apex:commandbutton value="getURL" onclick="newDoc({!$CurrentPage.parameters.urlpropertyname});"/>



Best Regards,
Mithun.

All Answers

MithunPMithunP
Hi practice.

You can use below sample codes.
<apex:inputField value="{!$CurrentPage.parameters.Paramtervalue}"/>
(OR)
<apex:page>
  <form method="GET">
    <input name="s" value="ValueEnteredInSearchBox" type="text" />
    <input type="submit" />
  </form>
</apex:page>
(OR)
<apex:page standardController="Account">
    <apex:pageBlock title="Hello {!$User.FirstName}!">
        You are displaying values from the {!account.name} account and a separate contact
        that is specified by a query string parameter.
    </apex:pageBlock>
    <apex:pageBlock title="Contacts">
        <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1">
              <apex:column>
               <apex:facet name="header">Name</apex:facet>
                {!contact.Name}
              </apex:column>
              <apex:column>
               <apex:facet name="header">Phone</apex:facet>
              {!contact.Phone}
              </apex:column>
        </apex:dataTable>
    </apex:pageBlock>
    <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/> 
</apex:page>

Best Regards,
Mithun.
k practicek practice
Hi Mithun,
            I want when i click a getURL button URL redirect to below mensioned URL.Here URL Redirected but value is not get

function newDoc() {
            window.top.location.href ='http://www.google.com/inquiry?property='+{!urlpropertyname};//urlpropertyname is apex variable
            alert({!urlpropertyname});
        }

<apex:commandbutton value="getURL" onclick="newDoc();"/>

URGENT please
MithunPMithunP
Hi Practice,

In your command button function you just pass required URL paramter. Below is the sample code to send parameters to javascript function
 
function newDoc(urlpropertyname) {
            window.top.location.href ='http://www.google.com/inquiry?property='+urlpropertyname;
            alert({!urlpropertyname});
        }

<apex:commandbutton value="getURL" onclick="newDoc({!$CurrentPage.parameters.urlpropertyname});"/>



Best Regards,
Mithun.
This was selected as the best answer