source: Dev/trunk/src/client/dojo/tests/_base/loader/afterOnLoad.html

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.6 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2        "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4        <head>
5                <title>Testing afterOnLoad</title>
6
7                <link rel="stylesheet" type="text/css" href="../../../resources/dojo.css"/>
8                <link rel="stylesheet" type="text/css" href="../../../../dijit/tests/css/dijitTests.css"/>
9                <link rel="stylesheet" type="text/css" href="../../../../dijit/themes/tundra/tundra.css"/>
10
11                <script type="text/javascript">
12                        function init(){
13                                //Create global dojoConfig object first. We cannot use the dojoConfig attribute
14                                //on the script tag since it may not be visible in some browsers at the time
15                                //dojo.js executes. This causes problems when the "require" property is used
16                                //as part of djConfig.
17
18                                //Previous versions of this test stated that baseUrl must be set explicitly because
19                                //the sniffing code would not work. As of 1.7, this seems to be unnecessary
20
21                                var startTime = (new Date()).getTime();
22
23                                var async = /async/.test(location.search);
24                                dojoConfig = {
25                                        async:async,
26                                        parseOnLoad:true,
27                                        afterOnLoad:true,
28                                        isDebug: true
29                                };
30                                var callback = function(){
31                                        dojo.byId("status").innerHTML =
32                                                "dojo.ready callback executed OK.<br>" +
33                                                "total load time: " + (((new Date()).getTime() - startTime) / 1000) + "s";
34                                }
35                                if(async){
36                                        dojoConfig.deps = ["dojo", "dojo/parser", "dijit/Calendar"]
37                                        dojoConfig.callback = callback;
38                                }else{
39                                        dojoConfig.addOnLoad = callback;
40                                        dojoConfig.require = ['dojo.parser', 'dijit.Calendar'];
41                                };
42
43                                var script = document.createElement("script");
44                                script.type = "text/javascript";
45                                script.src = "../../../dojo.js";
46                                document.getElementsByTagName("head")[0].appendChild(script);
47                        }
48
49                        function myHandler(id,newValue){
50                                console.debug("onChange for id = " + id + ", value: " + newValue);
51                        }
52                       
53                        //Register onload init function that will add Dojo to the page.
54                        if(window.addEventListener){
55                                window.addEventListener("load", init, false);
56                        }else{
57                                window.attachEvent("onload", init);
58                        }
59                </script>
60        </head>
61        <body>
62                <h1>Testing afterOnLoad</h1>
63
64                <p>This page tests loading dojo after the page is loaded. </p>
65
66                <p>Add the query string "?async" to the URL to test asynchronous operation; an empty query string results in
67                synchronous loading.</p>
68               
69                <p>When the window.onload fires, the dojo script tag will be added to the DOM
70                and configured to fire the onload callbacks. If everything works, you should
71                see a Calendar below.</p>
72
73                <p id="status"></p>
74               
75                <p class="tundra">
76                        <input id="calendar1" data-dojo-type="dijit.Calendar" onChange="myHandler(this.id,arguments[0])">
77                </p>
78        </body>
79</html>
Note: See TracBrowser for help on using the repository browser.