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
NIK_USANIK_USA 

Visualforce Redirect in Javascript not working

Hi
I am trying to override a new Contact page and Record Type Page. It is working fine in SF1 mobile but in browser it is not doing anything. Here is the code. The result will return RT ID and it is working fine. The problem is redirecting in browser. Any Help is really appreciated.

Thanks
NIK

<apex:page tabStyle="Contact" standardController="Contact" extensions="ControllerNewContactRedirect" title="Select Record Type" action="{!redirectPage}" id="L1">
    <apex:form id="L2">
        <script type="text/javascript">  
            function validate() {
               var vSelectedItem = (document.getElementById('L1:L2:L3:L4:L5:textRT')).selectedIndex;
               var vFieldName = document.getElementById('L1:L2:L3:L4:L5:textRT').options[vSelectedItem].value;
               Visualforce.remoting.Manager.invokeAction(
                    '{!$RemoteAction.ControllerNewContactRedirect.submitRecordType}',vFieldName, 
                    function(result, event){    
                        if (event.status) {
                            alert(result);
                                if( (typeof sforce != 'undefined') && (sforce != null) ) {
                                     sforce.one.createRecord('Contact',result);
                                 }
                                else{
                                    window.location.href ='www.google.com';
                                    //window.location.href ='apex/newCustomVFPage';
                                }
                        } else if (event.type === 'exception') {
                            alert(event.message);
                        } else {
                            alert(event.message);
                        }
                    }
                );
            }
        </script>
        
        <apex:pageblock id="L3">
            <apex:pageBlockButtons >
                <input type="button" value ="Submit" class="btn" onclick="validate();" />
            </apex:pageBlockButtons>            
            <apex:pageBlockSection id="L4">    
                <apex:pageBlockSectionItem id="L5">
                    <apex:outputLabel value="Select Record Type" for="textRT"/>
                        <apex:selectList value="{!selectedRT}" id="textRT" size="1">
                            <apex:selectOptions value="{!RT}"/>
                        </apex:selectList>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection> 
        </apex:pageblock>
    </apex:form>
</apex:page>
Sumit Kumar Singh 9Sumit Kumar Singh 9
Hello,

Have you tried "window.open" ?