| 1 | <html> |
|---|
| 2 | <script type="text/javascript" src="../dojo.js"></script> |
|---|
| 3 | <script type="text/javascript"> |
|---|
| 4 | dojo.require('dojo.html.common'); |
|---|
| 5 | dojo.require('dojo.html.style'); |
|---|
| 6 | dojo.require("dojo.event.*"); |
|---|
| 7 | dojo.require("dojo.lang.declare"); |
|---|
| 8 | |
|---|
| 9 | function $ (id) { return dojo.byId(id); } |
|---|
| 10 | function makeGreen (nodes) { for (var i = 0; node = nodes[i]; i++) { node.style.color = "green"; } } |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | var contentWin; |
|---|
| 14 | dojo.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 | |
|---|
| 22 | function 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 | |
|---|
| 30 | function 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 | |
|---|
| 39 | var ViewPort = {}; |
|---|
| 40 | ViewPort.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 | |
|---|
| 47 | function updateViewport() { |
|---|
| 48 | dojo.withGlobal(contentWin, "update", ViewPort, " updateViewport is clicked" ); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | function 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 | |
|---|
| 59 | dojo.event.connect("around", this, "init", this, "withEmbed"); |
|---|
| 60 | function 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> |
|---|