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
shravani milshravani mil 

how to write java script and displaying records

Hi 
I have two vf page and class VF_ Page VF_Class

When I click on the links under AB#, it should navigate to the respective Config page. how to use  Javascript to navigate to the respective pages.

suppose when i click on AB123 link it should navigate to https://salesforce.com.visual.force.com/apex/VisualForcePage_VF?visualforcepage=0005678799.
 
Manohar kumarManohar kumar

Hi Shravani ,

Pls try this..

<apex:page>
    <script>
       function f1() {
            
            var str = 'https://ascmanohar-dev-ed--c.ap2.visual.force.com/apex/OppView?id=0062800000Fx8Hu';
                alert('###'+str);
              
                var win = window.open(str, '_blank');
                    if (win) {
                        //Browser has allowed it to be opened
                    win.focus();
                    } else {
                        //Browser has blocked it
                    alert('Please allow popups for this website');
                    }
        }
    
    </script>
    <apex:form>
 <apex:commandLink value="save" onclick="f1()"/>
    </apex:form>
</apex:page>
 

Please let me know if this works.

Thanks,

Manohar

shravani milshravani mil
The above code is doing nothing in my case
Manohar kumarManohar kumar

Hi Shravani,

Sorry for the late reply. Have you tried changing url.

var str = 'https://ascmanohar-dev-ed--c.ap2.visual.force.com/apex/OppView?id=0062800000Fx8Hu';

put your url address here. URL/apex/vfPageName?id={recordID}

Please let me know if this works.

Thanks,

Manohar

shravani milshravani mil
Hi Manohar

Its taking me to the same link for different numbers as well.

Thanks.
Manohar kumarManohar kumar

Hi Shravani,

Please share your code. It will help me to debug.

Thanks,

Manohar

shravani milshravani mil
<apex:page>
 <script>
       function f1() {
          
        var str = ' https://salesforce.com.visual.force.com/apex/VisualForcePage_VF?visualforcepage=009567';
               alert('###'+str);
             
              var win = window.open(str, '_blank');
                    if (win) {
                      //Browser has allowed it to be opened
                    win.focus();
                  } else {
                       //Browser has blocked it
                    alert('Please allow popups for this website');
                  }        }
    
   </script>
   <apex:form>
 <apex:commandLink value="save" onclick="f1()"/>
    </apex:form>
</apex:page>
Manohar kumarManohar kumar

Hi Shravani,

Thanks, for the code.

https://salesforce.com.visual.force.com/apex/VisualForcePage_VF?visualforcepage=009567

here VisualForcePage_VF should be new page where you want to go .

If we want to pass id to a page then write like this::  https://salesforce.com.visual.force.com/apex/VisualForcePage_VF?id=0062800000Fx8Hu'

you wrote  https://salesforce.com.visual.force.com/apex/VisualForcePage_VF?visualforcepage=009567..

visualforcepage=009567 is wrong.

just write https://salesforce.com.visual.force.com/apex/VisualForcePage_VF

that will call that page.

Thanks,

Manohar