How to Overwrite function before it run?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mohammed R
    New Member
    • Oct 2010
    • 2

    How to Overwrite function before it run?

    Hi everybody :)
    I'm facing an issue while trying to display a page ( SAP BEx Report) on an IFrame.
    There is a javascript function inside the the page make it keep refection.
    I’m trying to overwrite this function before it run.
    The src for the IFrame page :
    Code:
    <html><head><LINK REL=stylesheet HREF="/irj/portalapps/com.sap.portal.design.portaldesigndata/themes/portal/ARAMCO/prtl_std/prtl_std_ie6.css?7.1.5.0.1">
    
    <!-- EPCF: BOB Core -->
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script src="/irj/portalapps/com.sap.portal.epcf.loader/script/optimize/js13_epcf.js?7.01000020"></script>
    <script>
    <!--
    EPCM.relaxDocumentDomain();
    EPCM.init( {
    Version:7.01000020,
    Level:1,
    PortalVersion:"7.0105.20090812092945.0000",
    DynamicTop:false, // [service=true nestedWinOnAlias=false]
    UAType:1, // [MSIE]
    UAVersion:8.0,
    UAPlatform:1, // [Win]
    UIPMode:"1", // [Default=1, User=0, Personalize=true]
    UIPWinFeatures:"",
    UIPPortalPath:"http://dvb.aramco.com.sa:52000/irj/portal",
    UIPPopupComp:"/irj/servlet/prt/portal/prtroot/com.sap.portal.epcf.admin.WorkProtectPopup",
    UIPPopupCompSize:"dialogWidth:450px; dialogHeight:200px; status:no",
    UIPPopupMsgNN:"",
    UIPPopupMsgND:"",
    DBGException:false
    } );
    EPCM.DSM.init( {
    TerminatorURL:"/irj/servlet/prt/portal/prtroot/com.sap.portal.dsm.Terminator",
    WinEmptyUrl:"/irj/portalapps/com.sap.portal.dsm/images/empty.gif",
    ForcedUserDebug:false,
    KeepAliveActive:false,
    KeepAliveDelta:840,
    KeepAliveStopAfter:36000
    } );
    function SAPWP_receiveSessInfo( sessInfo, frameRef ){
      EPCM.DSM.processSession( sessInfo, frameRef );
    }
    //-->
    </script>
    <!-- EPCF: EOB Core -->
    
    <script type="text/javascript">
    /*HTML Business for Java, 701_SP_TEST, 528954, Sat Jul 11 21:55:20 AST 2009*/
    ur_system = {doc : window.document , mimepath :"/irj/portalapps/com.sap.portal.design.urdesigndata/themes/portal/ARAMCO/common/", stylepath : "/irj/portalapps/com.sap.portal.design.urdesigndata/themes/portal/ARAMCO/ur/", emptyhoverurl : "/irj/portalapps/com.sap.portal.htmlb/jslib/emptyhover.html", is508 : false, dateformat : 1, domainrelaxing : "MINIMAL"};
    </script>
    <title >SAP NetWeaver Portal</title><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"></head><body class="prtlBody urFontBaseFam urScrl">
    <!-- EPCF: Component com.sap.portal.appintegrator.sap.BWReport, codjkaekngoeniemidleobclomgncaib -->
    
    <script>
    <!--
      function hasNestedFrameStructure() {
        try {
          return (parent != window) && (parent.EPCM != null);
        } catch(e) {
          return false; // access denied!
        }
      }
    //-->
    </script>
    
    <!-- Session Mangement Check -->
    
    <!-- HTTPRenderLayer_Redirect::Begin -->
    <form id="form_Redirect_9223372036563636042" 
      name="form_Redirect_9223372036563636042"
        method="POST"
        target="_self"
        action="/irj/servlet/prt/portal/prtroot/com.sap.ip.bi.web.portal.integration.launcher"
        style="DISPLAY:none">
          <input type="hidden" name="sap-bw-iViewID" value="pcd:portal_content/com.sap.pct/platform_add_ons/com.sap.ip.bi/iViews/com.sap.ip.bi.bex">
          <input type="hidden" name="sap-ext-sid" value="H6enlztSkkUZX7G*QhdSKA--Jt2cQdvkBs_*9RVvQeGETA--">
          <input type="hidden" name="Language" value="EN">
          <input type="hidden" name="QUERY" value="ZPS_PMIS_R_006_01">
          <input type="hidden" name="DUMMY" value="5">
          <input type="hidden" name="VARIABLE_SCREEN" value="X">
      </form>
    <div><iframe 
        id="iframe_Redirect_9223372036563636042" name="iframe_Redirect_9223372036563636042"
        title="BEx Web"
        src="/irj/servlet/prt/portal/prtroot/com.sap.portal.appintegrator.Loading?1887930939"
     	width="100%" height="100%"
        marginheight="0" border="0" frameborder="no">
      </iframe></div>
      <script> 
        function requestTargetURL() {
    	  var theForm = document.getElementById("form_Redirect_9223372036563636042");
    	  var dsmObj;
          if (hasNestedFrameStructure()) {
    	    dsmObj = parent.EPCM.DSM;
          } else {
            document.body.scroll = "no"; // for IE only
    	    theForm.target = "iframe_Redirect_9223372036563636042";
    	    document.getElementById("iframe_Redirect_9223372036563636042").style.visibility = "visible";
    	    dsmObj = EPCM.DSM;
            document.title = 'BEx Web';    
          }
              dsmObj.registerFullKey("GUSID:H6enlztSkkUZX7G*QhdSKA--Jt2cQdvkBs_*9RVvQeGETA--", "1288161886180");
          theForm.submit();
        }
    
        function onloadhandler(){
          setTimeout("requestTargetURL()",1);
        }
    </script>
      
      <form id="form_ClientWindowID_9223372036563636042" name="form_ClientWindowID_9223372036563636042"
        method="POST"
        target="_self"
        style="DISPLAY:none">
    	<!-- Request Parameters -->
      <input type="hidden" name="VARIABLE_SCREEN" value="X">
      <input type="hidden" name="ClientWindowID" value="null">
      <input type="hidden" name="DUMMY" value="5">
      <input type="hidden" name="QUERY" value="ZPS_PMIS_R_006_01">
    
        <input type="hidden" name="$Roundtrip" value="true">
        <input type="hidden" name="$DebugAction" value="null">        
      </form>
      <script>
        <!--
        function submitClientWindowIDForm(formTarget, formAction) {
          
          // set ClientWindowID Form-Field
          var theForm = setClientWindowIDForForm("form_ClientWindowID_9223372036563636042");
          
    	  // set Target
    	  if (formTarget != "_self") {
    	    theForm.target = formTarget;
    	  }
    	  
    	  if (formAction != null && formAction.length > 0) {
    	  	theForm.action = formAction;
    	  }
    	  
    	  // submit
          theForm.submit();
        }
        
        function setClientWindowIDForForm(formID) {
          var windowID = EPCM.getUniqueWindowId();
          var theForm = document.getElementById(formID);
    
          // add unique window ID to the form
          if (theForm.ClientWindowID != null) {
            theForm.ClientWindowID.value = windowID;
          }
    
          return theForm;
        }
        //-->		 	      
      </script>
    
    
      <script>
        <!-- 
       	  var trueWindowID = EPCM.getUniqueWindowId();
       	  if (trueWindowID != "null") {
       	    submitClientWindowIDForm("_self");
       	  } else {
       	    EPCM.subscribeEvent("urn:com.sapportals.portal:browser","load",onloadhandler);
       	  }
        //-->
      </script>
    <!-- HTTPRenderLayer_Redirect::End --></body></html>]

    The javascript function which causing the issue

    Code:
    function hasNestedFrameStructure() {
        try {
          return (parent != window) && (parent.EPCM != null);
        } catch(e) {
          return false; // access denied!
        }
      }
    I have try onload event, It doesn't work.
    The script inside the IFrame will run before onload event.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Can you change the source of the iframe?

    Comment

    • Mohammed R
      New Member
      • Oct 2010
      • 2

      #3
      Yes you can change source of the iframe.

      I have found that this is not the issue for me.
      The issue in the following code:

      in the iframe page at line 155 there is call for
      -- EPCM.getUniqueW indowId()
      function which call
      -- getSAPTop().
      and the 'getSAPTop' function always return top. However, top shows access denied error.

      Code:
      EPCM.getUniqueWindowId=function(){
      var wid=null;
      try{
      wid=this.getSAPTop().name;
      var rewrite=true;
      if( wid != null && typeof(wid) == "string" ){
      if (wid.indexOf("WID") == 0) rewrite=false;
      if (wid.indexOf("DefaultExternal") == 0) rewrite=false;}
      if(rewrite){
      this.getSAPTop().name="WID"+(new Date()).getTime();}
      return this.getSAPTop().name;
      }catch (ex){
      return null;}
      }
      EPCM.getSAPTop=function(){
      return (this._private.isDynamicTop) ? this._private.refDynamicTop : top;}

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        OK, so the problem's elsewhere. Where is _private defined? Perhaps you could just replace the function with top?

        Comment

        Working...