Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpvar committed Sep 18, 2010
1 parent 8e0528b commit a60bb1c
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,29 @@ console.log(window.document);

## Creating a browser-like DOM/Window

<pre>
var jsdom = require("jsdom"),
window = jsdom.jsdom().createWindow();
var jsdom = require("jsdom"),
window = jsdom.jsdom().createWindow();

window.document.innerHTML = "<html><head></head><body>hello world</body></html>";
console.log(window.document.innerHTML);
// output: '<html><head></head><body>hello world</body></html>'
window.document.innerHTML = "<html><head></head><body>hello world</body></html>";
console.log(window.document.innerHTML);
// output: '<html><head></head><body>hello world</body></html>'

console.log(window.innerWidth)
// output: 1024
console.log(window.innerWidth)
// output: 1024

console.log(typeof window.document.getElementsByClassName);
// outputs: function
</pre>
console.log(typeof window.document.getElementsByClassName);
// outputs: function

## jQuery
<pre>
var sys = require("sys"),
jsdom = require(__dirname + "/../../lib/jsdom"),
window = jsdom.jsdom().createWindow();

var sys = require("sys"),
jsdom = require(__dirname + "/../../lib/jsdom"),
window = jsdom.jsdom().createWindow();

// this also works:
// jQueryTag.src = "http://code.jquery.com/jquery-1.4.2.js";
jsdom.jQueryify(window, __dirname + "/jquery.js", function() {
window.jQuery('body').append("&lt;div class='testing'&gt;Hello World, It works!&lt;/div&gt;");
sys.puts(window.jQuery(".testing").text());
});
</pre>
jsdom.jQueryify(window, __dirname + "/jquery.js", function() {
window.jQuery('body').append("&lt;div class='testing'&gt;Hello World, It works!&lt;/div&gt;");
sys.puts(window.jQuery(".testing").text());
});



0 comments on commit a60bb1c

Please sign in to comment.