-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.js
34 lines (22 loc) · 983 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Here we go.
// We want to wait until the DOM is ready
// so we’ll wrap our bits in this function:
document.addEventListener( 'DOMContentLoaded', function(){
// Here’s the magic line.
// We’ll make “context” a global variable so you
// can inspect it yourself from the console.
window.context = getScriptContext( new Error )
// And some console output for you:
console.log( 'Here’s our context{} object:' )
console.log( context )
// And why not put this helpful stuff into HTML anyway?
// It’s kind of the medium of our times kiddo.
var el = document.createElement( 'div' )
el.innerHTML = '<strong>context.location.pathname</strong><br>'+
context.location.pathname +'<br><br>'+
'<strong>context.location.search</strong><br>'+
context.location.search +'<br><br>'+
'<strong>context.location.line : context.location.column</strong><br>'+
context.location.line +' : '+ context.location.column
document.body.appendChild( el )
})