Link to home
Start Free TrialLog in
Avatar of nielkotze
nielkotze

asked on

Preventing user from using webpage until it is fully loaded

Hi there Experts,

I would like to know what is the best way to prevent the user from using the webpage until it fully loaded.

On one of my pages, I have an iframe that loads just before the </body> tag.
On the same page I have a Javascript Calender that is activated by click on a image on the page, which calls the iframe.
(The Javascript calender is displayed in an iframe)

I have found that sometimes people click on the image to call the calender, BEFORE the <iframe>....... </iframe> code has been executed.

Is there a way to force the user to wait until the page is fully loaded?

Here is some source code:

// the javascript calender display in the iframe and insert the date value into the text box for Arrival Date//
           
<input type="text" id="RoomOneArrivalDate" name="RoomOneArrivalDate" size="12" onfocus="this.blur()" readonly>
 <a onclick="gfPop.fStartPop(document.gbi.RoomOneArrivalDate,document.gbi.RoomOneDepartureDate);return false;"
      onMouseOver="javascript:check_status()" HIDEFOCUS  href="javascript:void(0)">
     <img name="popcal" align="absbottom" src="calbtn.gif" width="34" height="22" border="0" alt="">
 </a>
.
.
.
.
.
// the javascript calender display in the iframe and insert the date value into the text box for Departure Date//

<input type="text" name="RoomOneDepartureDate" id="RoomOneDepartureDate" size="12" onfocus="this.blur()" readonly>
 <a onclick="gfPop.fEndPop(document.gbi.RoomOneArrivalDate,document.gbi.RoomOneDepartureDate);return false;"
       onMouseOver="javascript:check_status()" HIDEFOCUS href="javascript:void(0)">
       <img name="popcal" align="absbottom" src="calbtn.gif" width="34" height="22" border="0" alt="">
 </a>
.
.
.
.
<iframe width=174 height=189 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; left:-500px; top:0px;">
</iframe>

</body>
Avatar of enachemc
enachemc
Flag of Afghanistan image

use the <body onLoad="" .... > function to know when your page is finished loading.
Avatar of Michel Plungjan
or
<script>
loaded=false;

<input type="text" id="RoomOneArrivalDate" name="RoomOneArrivalDate" size="12" onfocus="this.blur()" readonly>
<a onclick="if (loaded) gfPop.fStartPop(document.gbi.RoomOneArrivalDate,document.gbi.RoomOneDepartureDate);return false;"
     onMouseOver="javascript:check_status()" HIDEFOCUS  href="javascript:void(0)"><img
name="popcal" align="absbottom" src="calbtn.gif" width="34" height="22" border="0" alt=""></a>

and in iframe do
parent.loaded=true
.
.
Avatar of nielkotze
nielkotze

ASKER

I know that I have to use a javascript in conjunction with the onLoad event....

What I don't know, is the javascript code how to actually do it
Oops ignore my previous posting..... i posted it before I saw the comment of mplungjan !
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok, :-)
I cannot type today anyway. loadec should be loaded
Hi there mplungjan,


<script>
loadec=false   <<<<== spelling error ? did you mean loaded=false ?
</script>


:-) just checking

Niel Kotze
Thanx mplungjan,

Your comment works ! but of course you knew that since you are the expert. Hehe

just by the way..... why the brackets around the loaded ?
just one of those javascript mysteries ?

<a onclick="if (loaded) gfPop.fStartPop.....
No mystery
the if statement syntax is ALWAYS

if (something in brackets that evaluates to true or false) do something

and I could write

if (loaded==true)

but if (loaded) is the same

Opposite test is

if (loaded==false)

and THAT can be written

if (!loaded)
- e.g. if NOT loaded

Michel