Skip to content

Instantly share code, notes, and snippets.

@fadyosman
Created October 18, 2022 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fadyosman/9dfd46510f0a18c46b8a1fbf6dec7834 to your computer and use it in GitHub Desktop.
Save fadyosman/9dfd46510f0a18c46b8a1fbf6dec7834 to your computer and use it in GitHub Desktop.
Sample for Javascript video
<html>
<head>
<title>JS monitor function demo</title>
<script src="main.js"></script>
</head>
<body>
<button onclick="add(1,2);">Call Add</button><br/>
<button onclick='makeRequest({"name":"test","url":"https://www.google.com/"});'>Call makeRequest</button><br />
<button onclick="first()">Read location.hash</button>
</body>
</html>
function add(x, y) {
return x+y;
}
function makeRequest(y) {
return true;
}
function first() {
second();
}
function second() {
var x = window.location.hash;
if(x.startsWith("#Render:")) {
var html = decodeURI(x.substring(8));
document.body.innerHTML = html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment