simsingh
asked on
onblur, onfocus not working iframe mozilla
I have the following code in my page:
<iframe id="the_editor_x5" onblur="TestMe();" onfocus="loadAlert();" name="the_editor_x5" width="99%" height="99%" style="Background:white;"> </iframe>
<textarea id="the_editorHtmlBox" runat="server" name="the_editorHtmlBox" class="" style="width:99%;font-size :10pt;font -family: Courier New, Courier;display:none" onchange="RTB_fromHTMLView ('the_edit or')"></te xtarea>
<input id="the_editor" runat="server" enableviewstate="true" name="the_editor" type="hidden" value="<p>&nbsp;< ;/p>" />
---------------
TestMe and loadAlert are two functions that simply call alerts. In IE, the alerts show up when I give focus to the iframe and take focus away. In Mozilla, the events never fire. Also, if I set the iframe's document.designMode etc to on, the events still don't fire in mozilla.
Does anyone have an idea as to why?
<iframe id="the_editor_x5" onblur="TestMe();" onfocus="loadAlert();" name="the_editor_x5" width="99%" height="99%" style="Background:white;">
<textarea id="the_editorHtmlBox" runat="server" name="the_editorHtmlBox" class="" style="width:99%;font-size
<input id="the_editor" runat="server" enableviewstate="true" name="the_editor" type="hidden" value="<p>&nbsp;<
---------------
TestMe and loadAlert are two functions that simply call alerts. In IE, the alerts show up when I give focus to the iframe and take focus away. In Mozilla, the events never fire. Also, if I set the iframe's document.designMode etc to on, the events still don't fire in mozilla.
Does anyone have an idea as to why?
Maybe you should try to assign the handlers to the window object of the iframe element by script:
<iframe id="the_editor_x5" name="the_editor_x5" width="99%" height="99%" style="Background:white;"> </iframe>
<script>
document.getElementById("t he_editor_ x5").conte ntWindow.o nfocus=loa dAlert;
document.getElementById("t he_editor_ x5").conte ntWindow.o nblur=Test Me;
</script>
<iframe id="the_editor_x5" name="the_editor_x5" width="99%" height="99%" style="Background:white;">
<script>
document.getElementById("t
document.getElementById("t
</script>
ASKER
no the content window onfocus onblur doesnt' work. Not doing any window.event stuff....
ITs really really strange....
ITs really really strange....
Ok and what about this:
<iframe id="the_editor_x5" name="the_editor_x5" width="99%" height="99%" style="Background:white;"> </iframe>
<script>
frames["the_editor_x5"].on focus=load Alert;
frames["the_editor_x5"].on blur=TestM e;
</script>
Doesn't it work at least in IE?
If it's working in IE and not FF, you should - as Zvenko supposed - look at your code in the handler.
window.event will not work with FF - nor Mozilla, nor Safari...
<iframe id="the_editor_x5" name="the_editor_x5" width="99%" height="99%" style="Background:white;">
<script>
frames["the_editor_x5"].on
frames["the_editor_x5"].on
</script>
Doesn't it work at least in IE?
If it's working in IE and not FF, you should - as Zvenko supposed - look at your code in the handler.
window.event will not work with FF - nor Mozilla, nor Safari...
The events are realy not fired in Mozilla. Very strange.
Mmm.. do not have FF here (am on my HTPC)..
Both frames and contentWindow failed to fire the event in FF?
Both frames and contentWindow failed to fire the event in FF?
OK, I have tested your both proposals.
Both proposals work in IE.
The folowing proposal does not work at all in FF:
<script>
frames["the_editor_x5"].on focus=load Alert;
frames["the_editor_x5"].on blur=TestM e;
</script>
But the first one:
<script>
document.getElementById("t he_editor_ x5").conte ntWindow.o nfocus=loa dAlert;
document.getElementById("t he_editor_ x5").conte ntWindow.o nblur=Test Me;
</script>
has an absolutely strange behavior.
On load of that page does not hapen anything. I mean you load the page and focus the iframe and leave the iframe and nothing happens and no errors.
But after that when you refresh the page does the onfocus event fire. Becaise the event handler calls an alert() does the iframe loose the focus but does not call the onblur handler. After clicking OK in the alert does the iframe fire again the onfocus handler, does alert and so on in an infinite loop. You need then the three fingers catch to kill the show by task manager.
Both proposals work in IE.
The folowing proposal does not work at all in FF:
<script>
frames["the_editor_x5"].on
frames["the_editor_x5"].on
</script>
But the first one:
<script>
document.getElementById("t
document.getElementById("t
</script>
has an absolutely strange behavior.
On load of that page does not hapen anything. I mean you load the page and focus the iframe and leave the iframe and nothing happens and no errors.
But after that when you refresh the page does the onfocus event fire. Becaise the event handler calls an alert() does the iframe loose the focus but does not call the onblur handler. After clicking OK in the alert does the iframe fire again the onfocus handler, does alert and so on in an infinite loop. You need then the three fingers catch to kill the show by task manager.
OH, and it does not help to coment out the onfocus alert(); the onblur handler does not fire also without alert()
So is this behaviour different from the one you'd get by writing this?
window.onfocus=loadAlert;
window.onblur=TestMe;
(am sorry again just trying to understand - as you do ;) -, but not having FF under the hand for testing)
window.onfocus=loadAlert;
window.onblur=TestMe;
(am sorry again just trying to understand - as you do ;) -, but not having FF under the hand for testing)
ASKER
Yeah its freak'n weird. No onfocus or onblur evetns fire. THE reason is that onblur, I want to copy the contents of the document to a textarea (to have a WYSYWIG editor). That didn't work in mozilla but worked great in ie. Thus, the testing I am doing with alerts and stuff, but basically, no onblur, or onfocus evetns fire...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
okay, so while I don't have a solution, if you do "onsubmit" on the form itself, one can then achieve what i wanted to achieve.
So we don't need to worry about this anymore.
I will distribute points evenly between the contributors.
So we don't need to worry about this anymore.
I will distribute points evenly between the contributors.
Hello simsingh,
the solution for your copy (when you have read my upper explanation) is to define the focus and blur handlers in the iframe page, not in the parent page. Iframe page can call parent functions by prefixing the parent. reference to the calls.
Like this:
<body onFocus="parent.loadAlert( )" onBlur="parent.TestMe()">
<h1>Iframe</h1>
</body>
the solution for your copy (when you have read my upper explanation) is to define the focus and blur handlers in the iframe page, not in the parent page. Iframe page can call parent functions by prefixing the parent. reference to the calls.
Like this:
<body onFocus="parent.loadAlert(
<h1>Iframe</h1>
</body>
Do you use window.event reference in that functions?
window.event is not defined in Mozilla.