Adding events to iframe javascript

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");

More to come soon


About ttessier

Professional Developer and Operator of SwhistleSoft
This entry was posted in Javascript Development, Web Development and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *