Quantcast
Channel: SwhistleSoft Blog » iframe
Viewing all articles
Browse latest Browse all 2

Adding events to iframe javascript

$
0
0

Technically it is possible to add events to an iframe but there are some caveats especially in terms of browser compatibility. for starters what I have found is that you can use the window object if you are trying to attach to events such as blur, drop, and mouse or keypress.

	ifrme = document.getElementById ( 'ifrme');
	if ( typeof ( ifrme.contentDocument ) != "undefined" ){
		var win = ifrme.contentWindow||iframe.defaultView;
		var doc = win.document;
		win.addEventListener ( "blur",function(){
			alert ( "blur");
		},false);
	}

More to come soon


Viewing all articles
Browse latest Browse all 2

Trending Articles