onBlur

JavaScript and client side scripting.

Moderator: General Moderators

Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

feyd wrote: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.
Thats very intresting knowledge.

So i need an alternate way...

I need to make sure the popup gets focus, and comes to top of other windows, when new content to it is opened. Anybody has a way of doing this?
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

I acidently deleted my last post :D

Anyway: I abandoned the onblur->close and made a decent opener function that puts focus to the popup, even if it was allready open.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Now i have it down! took a little more time than normal.

Code: Select all

<script>
function closeMe() {MyWindow.close()}
function doIt()
{
MyWindow=window.open('about:blank','SanastoKielet','toolbar=no'); 
MyWindow.focus(); 
MyWindow.document.body.onblur=closeMe; 
return false;
}
</script>
<A HREF="" onClick="return doIt()">Click Here</a>
howzzaat!:D
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

hmmm.. I'll have a look and see if that works for me too.. :D Would be great... Thanks n00b Sailbot.. :D
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Normally i don't have any probs with JS. this one caused a little prob because of the object model traversal required in it. was a rather crooked one. whatdya say :!: ;-)
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

MyWindow.document.body.onblur=closeMe;

Nice line, works only on IE thou.

But again, i'm a little bit wiser.
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

I've tried a lot of things now and it still doesn't work for me though.. :( I'll have a look to see if there is another way, since i also have probs switching the popup from no scrollbars to with scrollbars and vice versa...

Oh well eventually i'll get the hang of it.. LOL.. hopefully sooner than later.. heheheh
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

dreamline wrote:I've tried a lot of things now and it still doesn't work for me though.. :( I'll have a look to see if there is another way, since i also have probs switching the popup from no scrollbars to with scrollbars and vice versa...

Oh well eventually i'll get the hang of it.. LOL.. hopefully sooner than later.. heheheh
I got it to the part where it worked fine on opera nad firefor, but on IE it closed each time anything was clicked in the window. Not very handy. I abandoned the approach of closing the popups, and got it working.

Anyway, your problem is different. I guess it could be solved with javasript changing the properties of the window, or javascript changing the overflow-properties of a <DIV>. That way you could switch scrolling on and off...
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

I figured it out and the body onBlur thing works.. :D I also solved my scrollbars problem.. I use 2 different window names so that the scrollbar issue isn't an issue anymore... :D

Thanks guyz for all the input.... :D
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

Other problem that rises is that i can't use the popup to submit a form anymore.. LOL.. Oh well i'll keep trying.. heheheh

I decided to leave the popups, since for me it's essential that i can close after opening one.. Me as a user would go nuts if i have to close about 4-5 popups after closing my navigator.. So i decided to leave one popup in and the rest is out... Too much trouble for an easy think like that imho.. heheheh...

:D
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

All you need to do to bring a window into focus is

Code: Select all

windowName.focus
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Ignore that last msg.... I'm half asleep at work.... didn't nother to read the ful post LOL :lol:
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

LOL.. I got that sometimes too.. heheheh
Post Reply