473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Global event handler of new window being lost on location change

I am modifying existing code to add modal functionality to an IE5+
ActiveX Web-App. What I am trying to achieve is simple modal behaviour
on popup windows, apart from certain specified ones. I initially
attempted to use a direct assignment to the onblur handler of the new
window, but for some reason couldn't get it to work, so I've instead
used attachEvent. This provides simple modal functionality.

The problem that I need help with is that for some reason the attached
event handlers die when the page is reloaded or goes to another page.
I'm a little surprised as I would expect the global window event handler
to carry across reloads or location changes, and that's why I'm asking
for your help!

<script type="text/javascript">

var wOpen = null;

function DoNewWindow( sUrl, sTitle, sStyle, iWidth, iHeight )
{
wOpen = window.open(sUrl,sTitle,sStyle);
var bIsModal = true;
switch ( sTitle )
{
case 'Help' :
case 'UserAdmin' :
case 'Account' :
bIsModal = false;
break;
default :
break;
}
if ( bIsModal )
{
wOpen.attachEvent( 'onload', wOpen.focus );
wOpen.attachEvent( 'onblur', wOpen.focus );
}
}

</script>

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
8 5826
Fred Basset <fr*********@whosyourdaddy.com> writes:
The problem that I need help with is that for some reason the attached
event handlers die when the page is reloaded or goes to another page.
I'm a little surprised as I would expect the global window event handler
to carry across reloads or location changes,
It doesn't. The window object is reinitialized when a new page is loaded
into it.
and that's why I'm asking for your help!


With what?

You will have to assign the handler again on each page.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Sorry, I should have made myself more clear in my question. How can I
(if it's possible) carry across the modal functionality between the
window objects? I'd like to be able to setup all the necessary event
handling with the initial window-launch function, rather than having to
resort to hard-coding things into the actual pages of the popup window.

All I can come up with is the general idea that the onBeforeunload event
could capture the loss of the page, but I'm not sure how to set the new
event handlers ... if I set an onblur on the window with the
onbeforeunload then the event handling will be lost when the new page
comes in :/

Any suggestions or ideas would be gratefully received.

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
On 05 Sep 2003 21:12:24 GMT, Fred Basset
<fr*********@whosyourdaddy.com> wrote:
All I can come up with is the general idea that the onBeforeunload event
could capture the loss of the page, but I'm not sure how to set the new
event handlers ... if I set an onblur on the window with the
onbeforeunload then the event handling will be lost when the new page
comes in :/


Modify the windows properties to be modal using win32 API, or use a
modelessDialog, or use Zeepe http://www.zeepe.com/ rather than
hackish javascript solutions, when you're not in a default security
environment.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #4
I'm doing it centrally to cut down on development time. To convert all
the windows to proper IE modal dialogues is not a possibility.

If I can't do it in Javascript then I will have to set the onblur in
every individual popup page ... something I am not keen on doing. I do
realise that in an ideal world "hackish javascript solutions" are not to
be recommended, but I'm working on an antiquated GUI which could
possibly (hopefully) be replaced soon from scratch anyway ... there's no
point wasting valuable time if I can help it, hence the desire for a
pure javascript solution.

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
On 05 Sep 2003 22:42:28 GMT, Fred Basset
<fr*********@whosyourdaddy.com> wrote:
I'm doing it centrally to cut down on development time. To convert all
the windows to proper IE modal dialogues is not a possibility.

If I can't do it in Javascript then I will have to set the onblur in
every individual popup page ... something I am not keen on doing.


You do realise that the onblur "solution" doesn't even work reliably,
so I'm not sure what you're doing.

In a non-secure environment you can do it, using win32 API calls, (you
find the window, change the properties and make it modal, your app can
do this.) if that's too much learning from where you are now, then
there's the zeepe option which can do it easily, although that would
be a cost option.

Also, you could modify all IE's such that window.open was a call to a
modeless dialog, that gives you modeless dialog behaviour, without
having to change any behaviour other than capturing IE events.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #6
DU
Fred Basset wrote:
I'm doing it centrally to cut down on development time. To convert all
the windows to proper IE modal dialogues is not a possibility.

Resorting to showModelessDialog() should achieve your goals better than
an onblur attachEvent code which might not work well anyway.
If I can't do it in Javascript then I will have to set the onblur in
every individual popup page ... something I am not keen on doing.
This does not sound right to me. showModelessDialog() (or even
showModalDialog()) are reasonable straightforward javascript solutions
meeting your requirements.

I do realise that in an ideal world "hackish javascript solutions" are not to
be recommended, but I'm working on an antiquated GUI which could
possibly (hopefully) be replaced soon from scratch anyway ... there's no
point wasting valuable time if I can help it, hence the desire for a
pure javascript solution.


IMO, you're not saving time with onblur, onload attachEvent code ...

My 2 cents..

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #7
Thank you for your help guys ... I have indeed managed to use
showModalDialog. My hesitation arose from an ignorance about how it is
implemented ... I was worried about the fact that some of the popups are
required to be modal, but not all, but I have worked around the code. I
do however now have a new problem! :D

Some of the popups have 'tabs' which actually link to separate pages,
however clicking on the links pops up new browser windows pointing to
the login page rather than changing the location of the modal dialog ...
is this the only behaviour possible within a modal dialog, or can the
location be changed?

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #8
I need your help again, if possible.

I have decided to put an iframe (width,height 100%) inside the
modalDialog and then display the existing pages inside that. This
appears to work quite well, however when you resize the dialog (by any
amount), a border appears on the right hand side of the dialog box (in
the color of the background of the dialog itself), of about the width of
a scrollbar. I'm not quite sure what to do about this.

It appears to be peculiar to modalDialogs ... I've replaced the
showModal with window.open and the same problem does not occur. It only
occurs on resize, but I can think of nothing to solve it using the
iframe's onresize event handler, even though it definitely fires.

Anyone have any suggestions?

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Pai | last post by:
hello there, I am trying to rersize the window it works find in IE but doea not work with mozilla window.attachEvent(onload,MWSOnLoad); window.onload = function (MWSOnLoad) { alert('hello');...
7
by: Joakim Braun | last post by:
Why doesn't the below code work? I'm trying to create a global object and set an event handler to one of its methods. The function is called, but the object's mTest property is undefined. ...
0
by: beanweed | last post by:
BACKGROUND ---------- I have an ASP.NET application having two panels. In one panel, an XML document, transformed using xsl, is displayed. In the other panel are some controls that allow a user...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
0
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls...
3
by: LuB | last post by:
I'm writing a Win32 application - and more specifically, doing event programming. I want the application to be const compliant but I'm faced with a bit of a conundrum. Physically, many of my...
0
by: hynek.cihlar | last post by:
A strange behaviour thatI found in ASP.NET 2.0. I am trying to issue a callback request (handled by ICallbackEventHandler and RaiseCallbackEvent) and a regular GET request in the client browser...
6
by: Daz | last post by:
Hello everyone, I would like to open a child window from the parent, and add an onload event listener to the child window which will tell the parent when the document has loaded. As far as I...
3
by: thomson | last post by:
Hi All, i do have an website with the URL http://localhost/application/ASEAN-ANZ, Once i hit the application, it goes to the Global.asax. but after that if i tried to change the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.