root / trunk / tests / test_embedded_html.html

Revision 6847, 2.6 kB (checked in by bill, 2 years ago)

remove deprecated arguments, functions, files

Line 
1<html>
2<script type="text/javascript" src="../dojo.js"></script>
3<script type="text/javascript">
4dojo.require('dojo.html.common');
5dojo.require('dojo.html.style');
6dojo.require("dojo.event.*");
7dojo.require("dojo.lang.declare");
8
9function $ (id) { return dojo.byId(id); }
10function makeGreen (nodes) { for (var i = 0; node = nodes[i]; i++) { node.style.color = "green"; } }
11
12
13var contentWin;
14dojo.addOnLoad(function(){
15        contentWin = $("embed").contentWindow;
16        dojo.event.connect($("updateScroll"), "onclick", updateScroll);
17        dojo.event.connect($("updateScrollOffset"), "onclick", updateScrollOffset);
18        dojo.event.connect($("updateViewport"), "onclick", updateViewport);
19        dojo.event.connect($("init"), "onclick", init);
20});
21
22function updateScroll() {
23        dojo.withGlobal(contentWin, function() {
24                var scroll = dojo.html.getScroll();
25                $("scrollTop").firstChild.nodeValue = scroll.top;
26                $("scrollLeft").firstChild.nodeValue = scroll.left;
27        });
28}
29
30function updateScrollOffset() {
31        dojo.withGlobal(contentWin, function() {
32                var offset = dojo.html.getScroll().offset;
33                $("scrollOffsetX").firstChild.nodeValue = offset.x;
34                $("scrollOffsetY").firstChild.nodeValue = offset.y;
35        });
36}
37
38//use object context to invoke a member function of an object
39var ViewPort = {};
40ViewPort.update = function(msg){
41        var viewport = dojo.html.getViewport();
42        $("viewportWidth").firstChild.nodeValue = viewport.width;
43        $("viewportHeight").firstChild.nodeValue = viewport.height;
44        $("viewportSize").firstChild.nodeValue = viewport + msg;
45}
46
47function updateViewport() {
48        dojo.withGlobal(contentWin, "update", ViewPort, " updateViewport is clicked" );
49}
50
51function init() {
52        makeGreen(dojo.html.getElementsByClass("foo1 bar1"));
53        makeGreen(dojo.html.getElementsByClass("foo2", null, null, dojo.html.classMatchType.ContainsAll));
54        makeGreen(dojo.html.getElementsByClass("foo3 bar3", null, null, dojo.html.classMatchType.IsOnly));
55        makeGreen(dojo.html.getElementsByClass("foo4", null, null, dojo.html.classMatchType.IsOnly));
56}
57
58//use around to wrap a function to work in the embed window
59dojo.event.connect("around", this, "init", this, "withEmbed");
60function withEmbed(mi) {
61        dojo.withGlobal(contentWin, function() { mi.proceed(); });
62}
63
64</script>
65<head>
66</head>
67<body>
68<p>This text is before the iframe</p>
69<iframe id="embed" src="test_html_content.html" width="50%" height="200px"></iframe>
70<p><input type="button" id="init" value="Init green text">
71<input type="button" id="updateScroll" value="Update Scroll Values">
72<input type="button" id="updateScrollOffset" value="Update Scroll Values">
73<input type="button" id="updateViewport" value="Update Size Values"></p>
74<p style="height: 700px"></p>
75</body>
76</html>
Note: See TracBrowser for help on using the browser.