Skip to content

Instantly share code, notes, and snippets.

View hengsoheak's full-sized avatar

Heng Sopheak hengsoheak

View GitHub Profile
@thewinterwind
thewinterwind / disable_multiple_tabs.js
Created April 29, 2017 03:49
Detect website being accessed in a new tab
<script>
// helper function to set cookies
function setCookie(cname, cvalue, seconds) {
var d = new Date();
d.setTime(d.getTime() + (seconds * 1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
// helper function to get a cookie