JavaScript

Center a popup window on screen?

Use this Script in your Html.

<a href=”#” onclick=”javascript:MyPopUpWin()”>
<div class=”btn”>My Button</div>
</a>

<script type=”text/javascript”>
function MyPopUpWin() {
var iMyWidth;
var iMyHeight;
//half the screen width minus half the new window width (plus 5 pixel borders).
iMyWidth = (window.screen.width / 3) – (15 + 1);
//half the screen height minus half the new window height (plus title and status bars).
iMyHeight = (window.screen.height / 5) – (10 + 10);
//Open the window.
var win2 = window.open(“url”, “Window2”, “status=no,height=600,width=650,resizable=yes,left=” + iMyWidth + “,top=” + iMyHeight + “,screenX=” + iMyWidth + “,screenY=” + iMyHeight + “,toolbar=no,menubar=no,scrollbars=no,location=no,directories=no”);
win2.focus();
}
</script>

JavaScript

How to remove “#” from URL, after refresh page

Use this Script in your Html.

<script>
window.location.replace(“#”);

// slice off the remaining ‘#’ in HTML5:
if (typeof window.history.replaceState == ‘function’) {
history.replaceState({}, ”, window.location.href.slice(0, -1));
}
</script>