Skip to Content
Introducing .NET 4.0: with Visual Studio 2010
book

Introducing .NET 4.0: with Visual Studio 2010

by Alex Mackey
February 2010
Beginner content levelBeginner
400 pages
11h 13m
English
Apress
Content preview from Introducing .NET 4.0: with Visual Studio 2010

12.5. Running a Script on Page Load

One solution to the previous problem is to run the script inside the window.onload() function, but the script will not be run until the entire page including images is loaded.

jQuery offers a neat solution with the ready event:

$(document).ready(function() {
    $("<p>hello I am dynamic text</p>").appendTo("body");
});

This is a good way to ensure that the page is loaded before the script and will resolve the earlier issue. You must ensure that you have added any elements to the page before running code that manipulates them.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 For Dummies®

ASP.NET 3.5 For Dummies®

Ken Cox
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9781430224556Purchase book