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
    Oct 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    window.attachEvent issue

    I have a cross domain iframe resizing script (using postMessage) that works perfectly in Chrome, FF, Safari and IE9 - browsers that use addEventListener
    I'm trying to get it to work in IE8 by adding what I thought was the right language for attachEvent, but it's not working in IE8 - I just get 'Object doesn't support this property or method' - again just in IE8.
    Here's the js in the page with the iframe - What am I doing wrong ? Thanks.

    Code:
    <script type="text/javascript">
      function resize(id, other_domain) {
        var iframe = document.getElementById(id);
    
    if (window.addEventListener) 
    {
        window.addEventListener('message', function(event) {
          var howtall = parseInt(event.data); 
          iframe.height = howtall + "px";
        }, false);
    }
    else if (window.attachEvent) 
    {
        window.attachEvent('onmessage', function(event) {
          var howtall = parseInt(event.data); 
          iframe.height = howtall + "px";
        });
    }
              
    else {  alert('old browser');     }
    
      }
    window.onload = function(){resize('my_iframe', '*')}; 
    </script>

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts

  • #3
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the link - I did go through it, but it just seemed to indicate that the way I have it should be working.
    What specifically would need to be moved/changed? Thanks


  •  

    Posting Permissions

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