<!doctype html>
<body>
<p id="pddd"></p> <a href="#123">test</a>
<a href="#456">test456</a>
<br/>
<a href="leave#456">Click me and go to console</a>
<input type="button" onclick="fun();" value="test"></input>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<p id="456">Ther is very long paragraph. That's has to be on bottom of the page</p>
</body>
JavaScript
fun = function () {
console.log('test');
var el = document.getElementById('pddd');
console.log(el);
if (el !== undefined) {
el.appendChild(document.createTextNode('123'));
}
//console.log(this);
};
var link = document.getElementsByTagName('a')[2];
console.log(link);
link.onclick = function (event) {
console.log('leave');
console.log(event);
//console.log(this);
event.preventDefault();
event.stopPropagation();
window.location.href = "http://www.yandex.ru"
};
var scr;
window.onhashchange = function (event) {
window.alert("old: " + event.oldURL + "\nnew: " + event.newURL);
window.stop();
event.preventDefault();
event.stopPropagation();
//var scr = document.body.scrollTop;
//window.location.hash = ' ';
//document.body.scrollTop = scr;
};
window.onbeforeunload = function (event) {
window.alert("onbeforeunload: " + event);
event.preventDefault();
event.stopPropagation();
}
window.onscroll = function (e) {
//window.scrollTo(0,0);
//window.alert('attempt to scroll window');
};
fun();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.