const req = new XMLHttpRequest();
req.open("GET", "url", true);
req.send(null);
console.log(req.responseText);
* req.onreadystatechange = function(){console.log("ready")}
* req.readyState // === 4 (request finished)
* req.status // === 200 (response received)
* req.(setRequest|getResponse)Header()
<body id='body' onLoad='main()'>
<div id="top"></div>
<div id="bottom"></div>
</body>
<script>
document.getElementById('bottom').scrollIntoView();
</script>
<input id="btntest" type="button" value="Check"
onclick="window.location.href = 'http://www.google.com'" />
window.open(url)
# open url in new tabwindow.navigate("index.html")
# open url same tab (navigate)document.location.replace("index.html")
# open url same tab (replace)window.location.href
# urlwindow.location.hostname
# domain namewindow.location.pathname
# path and filename of current pagewindow.location.protocol
# protocl (http:)window.location.assign
# load documentRun other thread setTimeout(func, 0)
Global (The correct way) window.myglobal = 3;
keyword | meaning |
---|---|
var | function |
let | block |
const | constant |
[] | global |
window. | global |
var a = [1, 2, 3]
unescape("hello%20world")
substr(from, length)
substring(from, to)
process.version process.versions
var o = {1:2, "toto":3}
Object.keys(o).length
var a = 1; window['a'];
for (var prerty in obj){}