473,795 Members | 2,919 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(sUr l,sTitle,sStyle );
var bIsModal = true;
switch ( sTitle )
{
case 'Help' :
case 'UserAdmin' :
case 'Account' :
bIsModal = false;
break;
default :
break;
}
if ( bIsModal )
{
wOpen.attachEve nt( 'onload', wOpen.focus );
wOpen.attachEve nt( 'onblur', wOpen.focus );
}
}

</script>

Fred Basset
fr*********@who syourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
8 5856
Fred Basset <fr*********@wh osyourdaddy.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*********@who syourdaddy.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*********@wh osyourdaddy.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
onbeforeunlo ad 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.javas cript 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*********@who syourdaddy.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*********@wh osyourdaddy.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.javas cript 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 showModelessDia log() 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. showModelessDia log() (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*********@who syourdaddy.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*********@who syourdaddy.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
4918
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'); window.resizeTo(810,750); top.outerWidth=810;
7
2283
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. (What I'm trying to do is make a general-purpose solution for the situation where you have a list box with several associated form elements. When the element values are changed, you want to update the value of the selected list option, and when the...
0
1831
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 to change the xml. For example, each "l_item" element appears as a row in a table labelled with a "label"; so if I have <l_item id="1"> <label>blah</label> ...
1
11589
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 http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all out). Therefore, here goes my simple "web dialog box with parent event handler fireing" solution. ...
0
2474
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 which are not behaving as I would expect. Specifically, if there is a command button external to the usercontrol which is activated by a shortcut key (eg Alt-B), the command button Click event handler code 'executes' even though the textbox set...
3
1606
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 window methods can indeed be const Why? Many Win32 calls send msg to a WNDPROC - or event handler. Therefore, a const method may actually change something about a window. The 'value' of const is lost here.
0
2480
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 and handle them at the same time - in parallel. The funny thing is that the behaviour of the implementation I created depends on the existence of Global.asax in the Web application. Here is the source of the page that handles the regular GET...
6
19322
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 know, this shouldn't be an issue, but I just can't get it to work. The script only needs to work with Firefox/Mozilla, so XP code isn't an issue. I have tried to open a window like so.
3
2891
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 http://localhost/application/en-US, the global.asax is not fired.
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.