...

View Full Version : window.attachEvent issue



PeterJ
10-04-2011, 04:48 AM
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.


<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>

DaveyErwin
10-04-2011, 06:14 AM
This should help ...

http://help.dottoro.com/ljgheukc.php

PeterJ
10-04-2011, 02:30 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum