◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<body style="margin:10px;padding:10px">

<input type="button" onclick="alert('Like pressed on facebook.html!')" value="I LIKE IT !">

</body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
}
</style>

<div>Click to get rich now:</div>

<!-- The url from the victim site -->
<iframe src="facebook.html"></iframe>

<button>Click here!</button>

<div>...And you're cool (I'm a cool hacker actually)!</div>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<body style="margin:10px;padding:10px">

<input type="button" onclick="alert('Like pressed on facebook.html!')" value="I LIKE IT !">

</body>

Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
<body>

<div id="protector">
<a href="/" target="_blank">Go to the site</a>
</div>

<script>
Expand All @@ -31,11 +31,11 @@

</script>

This text is always visible.

But if the page was open inside a document from another domain, the div over it would prevent any actions.

<button onclick="alert(1)">Click wouldn't work in that case</button>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

<body>

<div>Changes top.location to javascript.info</div>

<script>
top.location = 'https://javascript.info';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

window.onbeforeunload = function() {
window.onbeforeunload = null;
return "Want to leave without learning all the secrets (he-he)?";
};

document.body.insertAdjacentHTML('beforeend', '<iframe src="iframe.html">');
Expand All @@ -31,11 +31,11 @@

<body>

<p>After a click on the button the visitor gets a "strange" question about whether they want to leave.</p>

<p>Probably they would respond "No", and the iframe protection is hacked.</p>

<button onclick="attack()">Add a "protected" iframe</button>

</body>
</html>
224 changes: 112 additions & 112 deletions 5-network/12-server-sent-events/article.md
24 changes: 12 additions & 12 deletions 5-network/12-server-sent-events/eventsource.view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@
<script>
let eventSource;

function start() { // when "Start" button pressed
if (!window.EventSource) {
// IE or an old browser
alert("The browser doesn't support EventSource.");
return;
}

eventSource = new EventSource('digits');

eventSource.onopen = function(e) {
log("Event: open");
};

eventSource.onerror = function(e) {
log("Event: error");
if (this.readyState == EventSource.CONNECTING) {
log(`Reconnecting (readyState=${this.readyState})...`);
} else {
log("Error has occured.");
}
};

eventSource.addEventListener('bye', function(e) {
log("Event: bye, data: " + e.data);
});

eventSource.onmessage = function(e) {
log("Event: message, data: " + e.data);
};
}

function stop() { // when "Stop" button pressed
eventSource.close();
log("eventSource.close()");
}
Expand All @@ -44,7 +44,7 @@
}
</script>

<button onclick="start()">Start</button> Press the "Start" to begin.
<div id="logElem" style="margin: 6px 0"></div>

<button onclick="stop()">Stop</button> "Stop" to finish.
Loading
Toggle all file notes Toggle all file annotations