Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cross domain issue in iframes Access denied error

    JS-error when trying to access contentWindow.document of the iframe: 'Access is denied'.
    But as I understand this error would get if rewards apps were not on the same domain I also tried setting the domain explicitly on the I Frame.
    Iframe.contentWindow.document returns "access is denied" error
    And I tried keep in several scenarios also.
    The major problem is different protocols : opening iFrame with HTTPS url from a parent page that is an HTTP


    jquery.iframe.js:-
    -----------

    $(document).ready(function()
    {
    // Set specific variable to represent all iframe tags.
    var iFrames = document.getElementsByTagName('iframe');

    // Resize heights.
    function iResize()
    {
    // Iterate through all iframes in the page.
    for (var i = 0, j = iFrames.length; i < j; i++)
    {
    // Set inline style to equal the body height of the iframed content.
    iFrames[i].style.height = getDocHeight(iFrames[i].contentWindow.document) + 'px';


    }
    }

    function getDocHeight(doc) {
    var ret = 0;
    if (typeof(doc) == "object" && doc != null) {
    if ("body" in doc && typeof(doc.body) == "object" && doc.body != null) {
    if ("scrollHeight" in doc.body) {
    ret = Math.max(ret, doc.body.scrollHeight);
    }

    if ("offsetHeight" in doc.body) {
    ret = Math.max(ret, doc.body.offsetHeight);
    }
    if ("clientHeight" in doc.body) {
    ret = Math.max(ret, doc.body.clientHeight);
    }
    }
    if ("documentElement" in doc && typeof(doc.documentElement) == "object" && doc.documentElement != null) {
    if ("scrollHeight" in doc.documentElement) {
    ret = Math.max(ret, doc.documentElement.scrollHeight);
    }
    if ("offsetHeight" in doc.documentElement) {
    ret = Math.max(ret, doc.documentElement.offsetHeight);
    }
    if ("clientHeight" in doc.documentElement) {
    ret = Math.max(ret, doc.documentElement.clientHeight);
    }
    }
    }
    return ret;
    }

    // Check if browser is Safari or Opera.
    if ($.browser.safari || $.browser.opera)
    {
    // Start timer when loaded.
    $('iframe').load(function()
    {
    setTimeout(iResize, 0);
    }


    // Safari and Opera need a kick-start.
    for (var i = 0, j = iFrames.length; i < j; i++)
    {
    var iSource = iFrames[i].src;
    iFrames[i].src = '';
    iFrames[i].src = iSource;
    }
    }
    else
    {
    // For other good browsers.
    $('iframe').load(function()
    {

    // Set inline style to equal the body height of the iframed content.
    this.style.height = this.contentWindow.document.body.offsetHeight+20 + 'px';


    }

    }

    }
    );

    rewards.jsp:--
    ---------

    <div id="rewardsAppWrapper">
    <iframe src='<%=iframeURL%>' name="rewardsApp" id="rewardsAppIframe" frameborder="0" width="100%" scrolling="auto"></iframe>
    <script type="text/javascript">
    alert(document.domain);
    </script>


    </div>


    iframeURL = EnvironmentUtil.getURL(request, response, "secure", "RewardsApplication/index.jsp?pipelineSessionId=" + PipelineSessionManager.getPipelineSessionID(request, response));

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,188
    Thanks
    10
    Thanked 569 Times in 550 Posts
    it won't work, you have to use postMessage and message event to talk between protocols.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • #3
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rnd me View Post
    it won't work, you have to use postMessage and message event to talk between protocols.


    i have tried could you please help me which code i need use.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •