472,965 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Newbie: Make a script wait for a full page to load JS/Chickenfoot


This is driving me crazy so I hope someone will help!

I am using chickenfoot and javascript to try and achieve something that should be really simple.

Basically a script that navigates through a series of preset URL's in order to populate the caches of our website.

so for ease lets say it has to surf through:


My problem is that the script just races ahead to the last link without waiting for the 1st two pages to load completely.
Now with chickenfoot (which is a firefox extension that basically extends the javascript API) I could use a (sleep) command between them. But the pages concerned could take 1 second or 90 seconds to load depending on the circumstances so setting a sleep is not very reliable.

so what I want is basically
load page1
wait for page to load fully
load page 2
wait for page to load fully
load page 3
wait for page to load fully

Can someone please help me with this very basic script!
Jun 19 '07 #1
5 4307
5,390 Expert Mod 4TB
... whoww ... that is much less basic as you might think ;)) ... until you load pages that are not your own (google.com, ...) you would have a problem with that ... knowing when the pages are ready might be possible for you with an onload of an iframe or frame wherever you load that page ... BUT: at the moment i'm not sure there is such a handler for frames? perhaps there might be something like a ready-state for a frame that you may ask for a change or something? ... i'll have a look at this in the evening today ... perhaps somebody has an other solution?

kind regards ...
Jun 19 '07 #2
Hi and thanks for the reply.

Just to be clear, these are our webpages but I just used the above URL's to protects some technically vunerable links :)

So lets say instead...


etc :)

I tell you what I have stumbled upon so far.

One is an onLoad method that is built into Chickenfoot but its very poorly documented and doesnt seem to work as you would expect.

Then their is
window.addEventListener("load",function() { progress.init(); }, false);

which I just don't understand lol

followed by something like


all of which is stretching my meagre JS skills to their limit and then some :)
I guess I am stuggling with putting these pieces together in a logical and correct manner. My programming experience is all from an earlier era (basic lol) and things were single threaded and very simple in those days. I am not good at building up this complexity of code.... sad isn't it!
Jun 19 '07 #3
5,390 Expert Mod 4TB
hmmm ... in this case there are simple ways ... to do that ... don't know what you have so far, but the main idea is: every page you load registers a counter or whatever in its own onload-event in that page where you want to start your script. when the counter matches a condition that you want to have fullfilled ... then start the processing of your script (something like: counter == 3 or whatever) ... you may setInterval and pull this information or you may trigger your execution from the onloads of your pages to load too ... that means ... one page registers onload in the parent page, asks for the counter-condition, calls the script in the parent that you want to have executed ...

hope this makes the idea clear?

kind regards ...
Jun 19 '07 #4
Your explanation is great, I know exactly what I want to do in my head... but getting it down in functional code form is (as always for me!!) the problem.

One important thing that maybe I haven't made clear is that this code does not reside in the pages themselves. Its an external script that chickenfoot firefox extension runs in the sidebar. So I think I have to do some naming of windows etc too I think.

In the head it sounds like this:

//configurables for the user to change parts of the url depending on which site they want to presurf
var leg = "webserver1";
// cc - the country code which the user wishes to presurf
var cc = "gb";
// lc - the language code which the user wishes to presurf
var lc = "en";

// non configurables
var windowname="window1"
var counter =0

// progress() a simple progress output for debugging and logging information
function progress() {
var currentUrl = window.location.href;
output(currentUrl+" has loaded");
// add +1 to counter

//running code

if counter = 0 then
window.location = "http://"+leg+".ourcompany.com/"+cc+"/"+lc+"/catalog/14369/";
window.onLoad = progress;
else exit

if counter = 1 then
window.location = "http://"+leg+".ourcompany.com/"+cc+"/"+lc+"/product/40825717";
window.onLoad = progress;
else ????????????????????

etc etc ??

Once the code is all complete I aim to package it all into a nice FF extension that the user can install and then set the variables through a nice little pop-up (ahhh dialogs.... another can of worms for me to get into later!!)
Jun 20 '07 #5
5,390 Expert Mod 4TB
may be ...i don't know the chickenfoot extension ... but one thing to notice:

to do a comparison in javascript you usually use:

Expand|Select|Wrap|Line Numbers
  1. if (variablevalue == something) {
  2. }
else you do an assignment ... ;) don't know whether cickenfoot works the same way or not?

kind regards ...
Jun 20 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Ed Brandmark | last post by:
I have a tag of the form <SCRIPT LANGUAGE="JavaScript1.1" SRC="foo.js"..... and was wondering if this delays the loading of my page until that file foo.js downloads. It seems that if I place...
by: Ola Fjelddahl | last post by:
hi. I load a script dynamically and it works * everytime with IE6. * sometimes! with Mozilla1.5 <- makes me curious * never with Opera7.11 all tests on WindowsXP. With "sometimes" I mean
by: Dennis M. Marks | last post by:
I have multiple functions that dynamically build parts of a page. It can take 15-30 seconds for this process to complete. In IE nothing appears until the page is complete. In Netscape parts of the...
by: cjl | last post by:
Hey all: I've searched the newsgroup, and googled, but I'm stuck. I want to be able to 'dynamically' add a .js file to a web page after the page has loaded, based on user interaction. For...
by: Stephajn Craig | last post by:
I have one page that may take a while to process on the server, and I'd like to implement a please wait message on this page when it posts back to the server and does its business. The page is...
by: janetb | last post by:
Brand new to xml and I'm trying to get Scott Mitchell's rss aggregator example working locally. Basically, involves a frameset with the channels(feeds) in the left frame, a list of items in the...
by: parkpost | last post by:
Hi Guys, I'm a total newbie trying to make a simple series of click buttons to load up different pages for a target frame on the low side of a page. Right now I'm still struggling with just the...
by: GiJeet | last post by:
Hello, I'm new to CSS and I see lots of examples where Javascript is used to apply styles to elements on page load - unobtrusive javascript - so I assume the CSS must be applied last before the...
by: idiolect | last post by:
Hi all - Sorry to plague you with another newbie question from a lurker. Hopefully, this will be simple. I have a list full of RGB pixel values read from an image. I want to test each RGB band...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.