473,773 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

window.open/window.navigate - how to tell when the URL has completed loading

Newbie question ... please respond to group

I'm trying to open/navigate to a url. How can I tell when the page is
fully loaded? Testing suggest that window.open returns before the
page is completely loaded and displayed. Likewise, window.navigate .
The code looks something like this:

wHandle = window.open( url, name, flags );
....
// how to tell when url is fully loaded and displayed
....
wHandle.navigat e( url );
....
// how to tell when url is fully loaded and displayed
....

I've tried setting wHandle.onload but that code does not seem to be
executing.

I'm stumped.

Thanks.
Jul 20 '05 #1
2 8311
Richard Bell wrote:
Newbie question ... please respond to group

I'm trying to open/navigate to a url. How can I tell when the page is
fully loaded? Testing suggest that window.open returns before the
page is completely loaded and displayed. Likewise, window.navigate .
The code looks something like this:

wHandle = window.open( url, name, flags );
...
// how to tell when url is fully loaded and displayed
...
wHandle.navigat e( url );
...
// how to tell when url is fully loaded and displayed
...

I've tried setting wHandle.onload but that code does not seem to be
executing.

I'm stumped.

Thanks.


Hi Richard,

Yes, that can be a problem, especially when the second page need some time
to load (serverside activity eg.)
A reliable way is to put a little script at the end of the page you are
loading that calls some javascriptfunct ion in the first window.

something like this:

page1.htm (the first window):

<script type="text/javascript">
var page2Loaded = false;
function IAmLoaded(){
page2Loaded = true;
alert("Page2 loaded!");
}
</script>
page2.htm (the long second window)

..... (long calculations or long page)...
at the end:
<script type="text/javascript">
opener.IAmLoade d();
// or was it opener.document .IAmLoaded() ?? test that. :P
</script>
</body>
</html>

even better could be:
<script type="text/javascript">
setTimeout("ope ner.IAmLoaded() " , 1000);
</script>

so you give the browser an extra second to finish the </body> and </html>
tag.

Alternatively you could also poll the second page from page1 for the
existance of some function you define at the end of that second page, but I
think the first method is easier.

Hope this helps.
Regards,
Erwin Moller
Jul 20 '05 #2
Erwin,

Thanks for the clue. Unfortunately, I have no control over the pages
I am loading so adding script to those pages is not an option.

Since my original post, I've done some more investigation and it would
appear that using wHandle.documen t.readystate may be an option under
IE 6 (but not other browsers). Also wHandle.addEven tListner( "load",
func_to_execute _when_window_lo aded, false); would appear to have
potential (it may be wHandle.documen t.addEventListn er(...), I'm not
sure). Unfortunately, attempts to use either of these techniques are
getting me in trouble. When I reference wHandle.documen t IE seems to
just go away. I'm able to move the windows, close them, etc. but
nothing in the javascript seems to be happening (including debug
statements).

If anyone out there has any insight, I'd very much appreciate a clue
regarding either the issue with referencing

wHandle = window.open( url, name, flags );
....

// is this an ok reference?
if (wHandle.docume nt.readystate.. .){}
....
// how does this work (anyone have an example that does)
wHandle.documen t.addEventListn er( "load", loadfunc, false);
....

Thanks,
Richard

On Mon, 09 Feb 2004 13:46:48 +0100, Erwin Moller
<si************ *************** *************** @spamyourself.c om> wrote:
Richard Bell wrote:
Newbie question ... please respond to group

I'm trying to open/navigate to a url. How can I tell when the page is
fully loaded? Testing suggest that window.open returns before the
page is completely loaded and displayed. Likewise, window.navigate .
The code looks something like this:

wHandle = window.open( url, name, flags );
...
// how to tell when url is fully loaded and displayed
...
wHandle.navigat e( url );
...
// how to tell when url is fully loaded and displayed
...

I've tried setting wHandle.onload but that code does not seem to be
executing.

I'm stumped.

Thanks.


Hi Richard,

Yes, that can be a problem, especially when the second page need some time
to load (serverside activity eg.)
A reliable way is to put a little script at the end of the page you are
loading that calls some javascriptfunct ion in the first window.

something like this:

page1.htm (the first window):

<script type="text/javascript">
var page2Loaded = false;
function IAmLoaded(){
page2Loaded = true;
alert("Page2 loaded!");
}
</script>
page2.htm (the long second window)

.... (long calculations or long page)...
at the end:
<script type="text/javascript">
opener.IAmLoade d();
// or was it opener.document .IAmLoaded() ?? test that. :P
</script>
</body>
</html>

even better could be:
<script type="text/javascript">
setTimeout("ope ner.IAmLoaded() " , 1000);
</script>

so you give the browser an extra second to finish the </body> and </html>
tag.

Alternativel y you could also poll the second page from page1 for the
existance of some function you define at the end of that second page, but I
think the first method is easier.

Hope this helps.
Regards,
Erwin Moller


Jul 20 '05 #3

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

Similar topics

18
8848
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page (same folder). The cookie is not received. Can someone explain why? I worked around this by adding a cache-control header with a value of no-cache. This fixes the problem. Unfortunately that causes another problem with Internet Explorer...
2
4649
by: Jawahar Rajan | last post by:
All, I have a printer friendly page that is opened when a user clicks a link on my page to get the printer friendly version, How ever when they close out the printer friendly version and return to the original page the mouse cursor is a Hour glass shape! my code: I use DIV tag <DIV id ="printThis"> <%
5
5099
by: Nicola Pedrozzi | last post by:
Here I really need a guru... ;^( I found out today with a big disappointment that : window.open("url", ...) and also navigate("url") limit the max length of the url string to something like 2080 characters. That on Explorer only; Netscape and Mozilla work perfectly
9
3465
by: Christopher Benson-Manica | last post by:
I have the following situation: Page A opens a window named 'foo'. Page A then reloads itself. Is there a way for the reloaded Page A to determine whether there is an open window named 'foo', *without* calling window.open? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
18
3350
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to the image. The desired behavior is that when the pop-up is invoked, I want the underlying window to stay put. I don't have this problem when I run the code on my local computer but I do have it when I run the code on geocities.
21
18177
by: alistair_henderson | last post by:
Morning All, I have some code for a website which uses 'window.open' to simulate modal dialog boxes. I use the window.closed property to decide if the window object exists at various points. This has been fine until last week when I started getting javascript 'Permission Denied' errors when I try to access this property. I suspect that a windows update has caused this somehow, as this code has not changed for a very long time. Can...
6
19311
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.
18
15928
by: Csaba Gabor | last post by:
Is there a straightforward way of implementing a PHP equivalent to window.setTimeout? In a javascript web app, it's often the case that things are done on an event driven basis. For example, html elements might have things like onclick="buttonClicked()" to indicate that the function buttonClicked should be run when that element is clicked. The analogue can be done in PHP (on Windows) using com_event_sink. In other words, you can...
1
6263
by: alnino | last post by:
Hi, On a form I have a command button that allows a user to browse for a file (PDF, Word, etc…). This command button then stores a hyperlink to the file within an associated txtfield in the table. The VB to browse for the file is as follows Private Sub CmdBuildingAdd_Click() Me!txtSelectedFile = BrowseFiles()
0
9621
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
9454
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
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
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...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
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.