Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Calling a function from another window


Message #1 by "Mark Irvine" <mark@m...> on Mon, 18 Feb 2002 09:15:03 -0000
Stanislavs,

Many thanks for your reply.  I had already been using the approach you
suggested, however I would have prefered a new window opening instead.  I'm
glad to say that I stuck at this and finally got it working.  Just in case
you or anyone else is interested here is the code I used:

On the page were there is likely to be a delay I provided the following two
functions:

function openWin()
{
 win = window.open("progress.htm", "progress", "height=150,width=400");
}

function closeWin()
{
 if (win && win.open && !win.closed)
 {
  win.close();
 }
}

I then made a call to the openWin function immediately after the body tag.

In the paged opened in the new window, I provided the following function to
centre the window:

function fixWin()
{
 var x = 400;
 var y = 150;
 window.moveTo(parseInt((screen.availWidth - x) / 2),
parseInt((screen.availHeight - y) / 2));
}

Mark

"Stanislavs Mudrijs" <stas@z...> wrote in message
news:147548@j...
>
> Hi there!
>
>
> just an idea how to make it easier.....
>
> if all you need is just show "Loading..." message while your main page is
> not loaded to the end use a couple of containers (DIV e.g.) and put all
> contents of your page in the first of them and "Loading" message in the
> second:
> ..
> <DIV id = "divContent" style = "display: none">
> ...
> all your page here
> ...
> </DIV>
>
> <DIV id = "divLoading" style = "display: block">
> Loading....Please wait
> </DIV>
>
> notice, container with your content is NOT visible, while your "Loading"
> message IS visible.
> Then, at the very end of your "onload" handler for the body element, just
> switch visibilities for your containers:
>
> ....
> function body_onload()
> {....
>        document.getElementById("divLoading").style.display = "block";
>        document.getElementById("divContent").style.display = "none";
> }
>
>
> hope this help
> good luck
>
> Stas
>
>
>
>
>
>
>
> -----Original Message-----
> From: Mark Irvine [mailto:mark@m...]
> Sent: Monday, February 18, 2002 11:15 AM
> To: javascript
> Subject: [javascript] Calling a function from another window
>
>
> Hi,
>
> I was wondering if it is possible to call a function from another window.
> The situation I am looking at is opening a new window using window.open
and
> then calling a function, in the newly opened window, that closes itself.
> Essentially I am trying to open a window that says 'Loading...' and then
> have the opening window close it when processing is complete.
>
> Mark
>
>
>
>
>
>



  Return to Index