Page 1 of 2
onBlur
Posted: Thu Dec 30, 2004 5:39 pm
by Shendemiar
I have links with anchors to popupped windows, but it's no good if the pop up stays behind the main windows.
For solution i've used <body onblur=windows.close> So the pop ups close when they are not looked at anymore. And pop up again to the front if links are pressed.
This works fine but it's not valid html/javascript. Is there any legal way to close window when it loses it's focus? Or to make pop up window came in front when it's contents update?
onBlur = myJavaScriptCode
Event handler for Button, Checkbox, FileUpload, Layer, Password, Radio, Reset, Select, Submit, Text, TextArea, Window.
See, it's not legal for body, thou all browsers i use supports it anyway. (Execpt IE who closes the popup window if link is clicked)
What's the layer?
How could the obBlur be triggered by Window?
Posted: Thu Dec 30, 2004 6:11 pm
by Shendemiar
Code: Select all
<SCRIPT type="text/javascript">
<!--
Window.onBlur="alert("Blur")"
-->
</SCRIPT>
Does nothing.
How can i trigger the window.onBlur
Posted: Thu Dec 30, 2004 6:48 pm
by Shendemiar
Code: Select all
<A HREF="./"
onClick="MyWindow=window.open('index.php?MM=sanasto_kielet',
'SanastoKielet','toolbar=no'); MyWindow.focus; return false;)"
>
What do i need to add to close a windows named SanastoKielet if one exists Or make it really get focus if it's allready open.
Posted: Thu Dec 30, 2004 6:56 pm
by feyd
try something like this:
Code: Select all
function closeMe()
{
window.close();
}
window.onblur = closeMe;
you can edit your posts, you know.
Posted: Fri Dec 31, 2004 4:39 am
by n00b Saibot
If I try ur code in IE it reports an error "Not Implemented!"
Posted: Fri Dec 31, 2004 5:28 am
by Shendemiar
n00b Saibot wrote:If I try ur code in IE it reports an error "Not Implemented!"
Not for me. I had success with feyds code, but i don't still understand why it works while
window.onblur ="window.close"
doesn't
Posted: Fri Dec 31, 2004 5:46 am
by n00b Saibot
yer wrong! it works only when window refers to the parent window. when i changed it to refer to the opened window the code had no effect at all.
can ya tell me how it works in ur case...
Posted: Fri Dec 31, 2004 5:47 am
by Shendemiar
n00b Saibot wrote:yer wrong! it works only when window refers to the parent window. when i changed it to refer to the opened window the code had no effect at all.
can ya tell me how it works in ur case...
I have these:
In heaad
Code: Select all
<!-- JavaScript -->
<SCRIPT type="text/javascript">
<!--
function closeMe()
{
window.close();
}
-->
</SCRIPT>
<!-- JavaScript -->
In Body
Code: Select all
<!-- JavaScript -->
<SCRIPT type="text/javascript">
<!--
window.self.name = "<?=$Wname?>";
<?=$Blur?>
-->
</SCRIPT>
<!-- JavaScript -->
Where
$Wname = "just some name"
$Blur = "window.onblur = closeMe;\n"
Posted: Fri Dec 31, 2004 5:49 am
by Shendemiar
Ok, now i have the onblur->close done legally, but i still have problem.
In IE: Clicking on a link (or anywhere in the page) closes the popup before the link opens.
In Firefox: Losing a focus makes nothing happen. (I don't care about this)
In Opera: Works perfectly in all aspects.
How come the window loses the focus if a text inside the window is clicked?
Any way around this?
Posted: Fri Dec 31, 2004 5:50 am
by n00b Saibot
Yes, that's the thing happening to me all the time in IE since i am trying to solve ur code
Posted: Fri Dec 31, 2004 8:39 am
by feyd
technically, each textbox is a window too. that's why it loses focus. Although, I don't remember the blur event getting called when that happened, as that's just a windows thing.
Posted: Fri Dec 31, 2004 10:00 am
by dreamline
I'm having the same prob, and i'm also still working on a solution.. If i find one i'll post a reply again...

Posted: Fri Dec 31, 2004 7:16 pm
by Shendemiar
feyd wrote:technically, each textbox is a window too. that's why it loses focus. Although, I don't remember the blur event getting called when that happened, as that's just a windows thing.
Windows thing or IE thing? It does not happen on Fireofx or Opera. And clicking on any part of the page makes it happen, not just textboxes.
Posted: Sat Jan 01, 2005 12:33 am
by feyd
Textboxes, buttons, dialogue boxes, all kinds of stuff are windows in Windows. This may be true in other OS's as well, I'm not sure.
The reason you only get it in IE is likely because of the event model used. Although I can't say for sure, in any real direction.
Posted: Sat Jan 01, 2005 12:56 am
by n00b Saibot
Yeah, that's right. imo the true culprit in IE is the event model
