Skip to main content Take our 5-minute Community Survey. Open now through 4/11/2025. Click here to participate.
Using a standard controller I am trying to use jQuery to redirect my page.  It does not work.  I am new to jQuery, can someone identify the problem

<apex:page standardController="Request_Chemical__c" sidebar="false" >

    <apex:includeScript value="$Resources.jQuery" />

    

    <script >

    var returnURL='/apex/Recommendation_Request_Dataview';

        function redirectPage(){

              $(location).attr('href' returnURL);

        }

    </script>

    

    <apex:form >

        <apex:pageBlock title="Chemical Exposure" >

           <apex:pageBlockSection >

            <apex:inputField value="{!Request_Chemical__c.Recommendation_Request__c}" /><br/>

            <apex:inputField value="{!Request_Chemical__c.Chemical__c}" /><br/>

            <apex:inputField value="{!Request_Chemical__c.Percentage__c}" />

        </apex:pageBlockSection>

        

            <apex:pageBlockButtons >

                <apex:commandButton action="{!Save}" oncomplete="redirectPage" value="Save" />

               <apex:commandButton action="{!Cancel}" value="Back" /> 

         </apex:pageBlockButtons>

        </apex:pageBlock>

 

    </apex:form>

  

</apex:page>
2 answers
  1. Dec 16, 2017, 3:06 PM
    I made the changes but it still does not work.  I set the following test page and this does not redirect the page. Any thoughts.

    <apex:page >

         <apex:includeScript value="{! $Resource.jQuery }"/>

        

        <script >

        var returnURL='/apex/Recommendation_Request_Dataview';

            function redirectPage(){

                  $(location).attr('href', '{$Page.Recommendation_Request_Dataview}');

            }

        </script>

        

        

        <apex:form>

        

            <apex:commandButton value="Move" onclick="redirectPage" />

        

        

        

        </apex:form>

    </apex:page>
Loading
0/9000