Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created March 5, 2010 13:09
Show Gist options
  • Save phiggins42/322704 to your computer and use it in GitHub Desktop.
Save phiggins42/322704 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>SuperBasic Dojo Page</title>
<!-- load dojo from a CDN -->
<script src="http://o.aolcdn.com/dojo/1.4/dojo/dojo.xd.js"></script>
<script>
// document is ready for DOM action
dojo.ready(function(){
// update the title
dojo.byId("header").innerHTML = "Hello, Dojo";
// fetch this page via XHR
dojo.xhrGet({
url:window.location,
load:function(data){
// add a new <p> explaining what is happeneing
dojo.place("<p>Here is the source of this page:</p>", "content", "before");
// set the <pre> tag content to the data after replacing <'s to html-entities
dojo.byId("content").innerHTML = data.replace(/</g, "&lt;");
}
});
// make the <pre> tag prettier, should do this in CSS really.
dojo.style("content", {
backgroundColor:"#ededed",
border:"1px solid #666",
color:"#101010",
padding:"18px"
})
});
</script>
</head>
<body>
<h1 id="header">Hello, World.</h1>
<pre id="content"></pre>
</body>
</html>
@techslides
Copy link

Cool, you can see live version here: http://browsercode.com/#gist=322704

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment