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
jungleeejungleee 

unable to access DOM elements of standard page from jQuery in inline VF page

Hi Guys,

 

I have created a simple vf page and placed and small jQuery script in the vf page (below code). I have added this vf page as an inline VF page in the Case detail page. In the jQuery I am trying to pick up the case number by passing the id of the div in which the case number is present and alerting the result. But I am getting a blank pop-up.

But when I try the same, by placing the jQuery in the sidebar, its working just fine.

 

<apex:page standardController="Case">
<script src="/resource/jQueryLatest" type="text/javascript"></script> <script type="text/javascript"> j$(document).ready(function(){ var caseNumber = j$("#cas2_ileinner").text(); alert(caseNumber); }); </script>
</apex:Page>

 Problem: not able to access the DOM elements of the standard detail page from a jQuery script which is placed in the inline vf page on the same page.

 

please help!

 

Regards

Sam

 

 

Best Answer chosen by Admin (Salesforce Developers) 
jungleeejungleee

Hi RItesh,

 

Thanks for the reply. I had placed the noConflict statement, but forgot mention it in the below code, thanks for pointing that out. But also got to know that one cannot access the standard page's DOM element from a jQuery script placed in a inline VF page.

 

Thanks

Sameer

All Answers

Ritesh AswaneyRitesh Aswaney

The embedded VF Page is a (child) iframe of the main parent window, therefore try this

(Also you need to use .noConflict as $ is also a sort of a reserved symbol for Global Variables in Visualforce)

 

  var j$ = jQuery.noConflict();        
        j$(document).ready(
            function() {
               
                    j$(window.parent.document.getElementById('#case2_ileinner')).text();
                }    
            }
        );          
jungleeejungleee

Hi RItesh,

 

Thanks for the reply. I had placed the noConflict statement, but forgot mention it in the below code, thanks for pointing that out. But also got to know that one cannot access the standard page's DOM element from a jQuery script placed in a inline VF page.

 

Thanks

Sameer

This was selected as the best answer