473,772 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

making sure page loads

hey all,
i have a button on my web form that after it posts back it suppose to throw
up an alert. it works fine but that it throws the alert before the entire
page has been displayed. is there any way i can get it to display the alert
after the entire page is displayed?

thanks,
rodchar
Sep 5 '06 #1
2 1182
Rob
rodchar,

To do this you need to display the alert from the BODY tag's onload method.

OnLoad can be a bit of a pain to handle correctly, especially if you have 2
or more bits of code that need OnLoad handlers, not to mention cross browser
support.

Here's a chunk of code I like for onload (handles multiple onload handlers
and is cross browser compatabile):

//
// Add the addLoadEvent function
// - A clean cross browser method to add a window.onload method
//
ClientScript.Re gisterClientScr iptBlock(this.G etType(), "addLoadEve nt",
"function addLoadEvent(fu nc) { var oldonload = window.onload; if (typeof
window.onload != 'function') { window.onload = func; } else { window.onload
= function() { if (oldonload) { oldonload(); } func(); } } }", true);

More or less the above checks if there is an existing OnLoad handler. If
there isn't then the function passed as the argument is used. If there is an
existing onload handler then a new function is defined that calls the
existing onload handler and then calls the function passed as the argument.
This new function is then setup as the onload handler.

With that javascript function defined,you can then add as many onload
handlers as you need. To display an alert after the page has fully loaded:

string ShowMyAlert = "addLoadEvent(f unction() { alert('hello'); });";
ClientScript.Re gisterStartupSc ript(this.GetTy pe(), "ShowMyAler t",
ShowMyAlert, true);

Regards,

Rob
"rodchar" <ro*****@discus sions.microsoft .comwrote in message
news:61******** *************** ***********@mic rosoft.com...
hey all,
i have a button on my web form that after it posts back it suppose to
throw
up an alert. it works fine but that it throws the alert before the entire
page has been displayed. is there any way i can get it to display the
alert
after the entire page is displayed?

thanks,
rodchar

Sep 5 '06 #2
thank you for the help.

"Rob" wrote:
rodchar,

To do this you need to display the alert from the BODY tag's onload method.

OnLoad can be a bit of a pain to handle correctly, especially if you have 2
or more bits of code that need OnLoad handlers, not to mention cross browser
support.

Here's a chunk of code I like for onload (handles multiple onload handlers
and is cross browser compatabile):

//
// Add the addLoadEvent function
// - A clean cross browser method to add a window.onload method
//
ClientScript.Re gisterClientScr iptBlock(this.G etType(), "addLoadEve nt",
"function addLoadEvent(fu nc) { var oldonload = window.onload; if (typeof
window.onload != 'function') { window.onload = func; } else { window.onload
= function() { if (oldonload) { oldonload(); } func(); } } }", true);

More or less the above checks if there is an existing OnLoad handler. If
there isn't then the function passed as the argument is used. If there is an
existing onload handler then a new function is defined that calls the
existing onload handler and then calls the function passed as the argument.
This new function is then setup as the onload handler.

With that javascript function defined,you can then add as many onload
handlers as you need. To display an alert after the page has fully loaded:

string ShowMyAlert = "addLoadEvent(f unction() { alert('hello'); });";
ClientScript.Re gisterStartupSc ript(this.GetTy pe(), "ShowMyAler t",
ShowMyAlert, true);

Regards,

Rob
"rodchar" <ro*****@discus sions.microsoft .comwrote in message
news:61******** *************** ***********@mic rosoft.com...
hey all,
i have a button on my web form that after it posts back it suppose to
throw
up an alert. it works fine but that it throws the alert before the entire
page has been displayed. is there any way i can get it to display the
alert
after the entire page is displayed?

thanks,
rodchar


Sep 6 '06 #3

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

Similar topics

1
1854
by: CST | last post by:
Hi All, I have a "Digital Dashboard" that basically has 4 IFrame sections. The page flows in the following order: Messages, Stocks, Weather, User Links. Please note that this order needs to stay that way. Everything but the Stocks section is pulled from our dB. I am using the server control InetCtls.Inet to obtain the stock data from Yahoo Finance. The question I have is can I load the page using the dB driven sources
1
2945
by: middletree | last post by:
For an ASp Intranet app, I have some code that should work, but I am not able to make it happen for some reason, after spending considerable time on this. I am pretty thick when it comes to javascript; I just don't get the syntax at all. If anyone could help, I would appreciate it. I'm probably pretty close. Please note that because it's an Intranet, all users have to use IE 5 or higher. Situation: 3 form fields on an ASP. <select>...
7
2074
by: Sens Fan Happy In OH | last post by:
I'm having majour issues with FrontPage 2K and a webpage that I am having to create from scratch based on someone else's prior work. I hope someone can look at the source code for the page in question and tell me where my code is going wrong that I am getting things to load incorrectly. The situation is this: The owner wants "picture pages" that can be printed out exactly as fliers and pages that were created for print years ago. ...
1
1490
by: mark | last post by:
Hi I am trying to count the number of times a page loads. When I hit the submit button I can get the page to count once using ispostback to check . I am trying to incriment a variable everytime the page loads. It will only do it one time even if I put the variable = variable + 1 statement into the button click event. Any ideas as to how to count the number of times a page loads? Thanks
351
13130
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and do) occur in any language. These assumptions are generally made because of familiarity with the language. As a non-code example, consider the idea that the faulty code is written by blackguards bent on foulling the language. The term...
3
2888
by: Alex | last post by:
Sorry if this is not a correct forum to post to. I have a page from my service provider that loads 1000's of table cells. These cells load for 3-4 mins and links on that page usually not available untill the whole page loads. I need to find a way to "skip" load of these cells. Problem is that GreaseMonkey work only on a fully loaded page. What happens is that the page loads 3-4 mins and then the cells go away once the page loads and...
8
1991
by: yawnmoth | last post by:
A webpage can include any number of images, cascading stylesheets, frame's, etc. How might I go about making it so a particular image loads before any of these others? Ideally, the image would load even before the rest of the page loaded. Any ideas as to how this might be done? (I'm asking because I'm using a 1x1 image to simulate a cron job)
10
2065
by: Antha | last post by:
Hi! I have a small e-commerce site but for everything else webrelated I'm practically virgin... I'd like to offer some sort of quiz in my shop so people can interactively find out which products suits them best. They should be able to answer some short questions (type: is your skin a. oily b. sensitive c.dry d.normal) and their score should be added up, resulting in their best-matching (in this case skin care) program. A friend of mine...
0
3561
by: Andrus | last post by:
MSDN Winforms DataGridView VirtualMode with caching sample code DataRetriever loads two pages always to cache thus making 2 database accesses. If datagridview uses one page of data, second page retrieval is unnessecary and makes DataGridView display 2 times slower. How to change this sample code so that only one page is loaded initially and second is loaded on real demand only ? How to change this code so that it allows more than 2...
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
10261
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
10104
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...
0
9912
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
8934
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
7460
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
6715
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();...
1
4007
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
2850
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.