[Assorted-commits] SF.net SVN: assorted:[1842] sandbox/trunk/src/web
Brought to you by:
yangzhang
From: <yan...@us...> - 2012-10-03 11:10:24
|
Revision: 1842 http://assorted.svn.sourceforge.net/assorted/?rev=1842&view=rev Author: yangzhang Date: 2012-10-03 11:10:14 +0000 (Wed, 03 Oct 2012) Log Message: ----------- Add html/js frames sandbox Added Paths: ----------- sandbox/trunk/src/web/frames/ sandbox/trunk/src/web/frames/Makefile sandbox/trunk/src/web/frames/frame.jade sandbox/trunk/src/web/frames/frames.jade Added: sandbox/trunk/src/web/frames/Makefile =================================================================== --- sandbox/trunk/src/web/frames/Makefile (rev 0) +++ sandbox/trunk/src/web/frames/Makefile 2012-10-03 11:10:14 UTC (rev 1842) @@ -0,0 +1,3 @@ +all: frames.html frame.html +%.html: %.jade + jade $< Added: sandbox/trunk/src/web/frames/frame.jade =================================================================== --- sandbox/trunk/src/web/frames/frame.jade (rev 0) +++ sandbox/trunk/src/web/frames/frame.jade 2012-10-03 11:10:14 UTC (rev 1842) @@ -0,0 +1,14 @@ +doctype 5 +html + head + style + .foo { color: red; } + body + .foo Hi + script(type='text/javascript', src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js') + script(type='text/javascript') + function doit() { + console.log(getMatchedCSSRules===window.getMatchedCSSRules); + console.log(getMatchedCSSRules===document.defaultView.getMatchedCSSRules); + return getMatchedCSSRules($(".foo").get(0)); + } Added: sandbox/trunk/src/web/frames/frames.jade =================================================================== --- sandbox/trunk/src/web/frames/frames.jade (rev 0) +++ sandbox/trunk/src/web/frames/frames.jade 2012-10-03 11:10:14 UTC (rev 1842) @@ -0,0 +1,20 @@ +doctype 5 +html + head + body + iframe(src='frame.html') + script(type='text/javascript', src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js') + :coffeescript + window.frame = null + # document onLoad doesn't wait for iframes + $ -> + # Wait for iframes to load + $('iframe').ready -> + # contentWindow same as (in the frame) document.defaultView + # document obtained via $('iframe').contents().get(0) + window.frame = $('iframe').get(0) + console.log(window.frame.contentWindow.doit()) + console.log(window.frame.contentWindow.getMatchedCSSRules($('iframe').contents().find('.foo').get(0))) + console.log(window.getMatchedCSSRules($('iframe').contents().find('.foo').get(0))) + + # FYI: objects in window are global to framed scripts as well This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |