I would offer you to use apex:detail as your solution.Below is the code example <apex:page standardController="Event"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script> $(document).ready(function(){ ReadyFunc(); }); function ReadyFunc(){ var a = $('[value$=pections]').first().attr('onclick'); $('[value$=pections]').first().attr('onclick','ShowPopup();'+a); } <apex:detail relatedList="true" inlineEdit="true" relatedListHover="true" oncomplete="ReadyFunc();"/> </apex:page> You can do anything you want inside ypur document ready function automatically. more information about : [apex:detail][1] [1]: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_detail.htm