Self-esteem and centering the window using javascript (no jquery) when loading the page

This is not what we usually did, but we are trying to load the video into an empty window, opened by clicking the clickTag button (from the banner advertisement), and make it look as large as a modal window.

Is it possible to use javascript to independently change a blank window opened with a mouse click and center it on the screen?

  • We cannot apply anything to a link that was clicked like this ...
  • Everything should be done when the page loads.
  • If possible, it would be nice not to see the tabs and browser address bar
  • We do not load jquery
  • Does browser security warn of a potential problem?

In fact, the user clicks to watch the video, and we would like them to watch the video without their feeling that they went to a completely different site.

So far I can resize the window, but I cannot figure out how to center it:

<script language="javascript">

  function resizeVideoPage(){
    resizeTo(400,390);
    window.focus();
  }
</script> 

// Then...

<body onload="resizeVideoPage();"></body>

Any pointers in the right direction would be highly appreciated.

Greetings

Ben

+5
source share
2 answers

I personally would advise Popups to manipulate Javascript windows. (due to popup blockers, Javascript errors, ...) Overlay would probably be better.

There will be another solution here.

There is only one file (the link should point to this helper, which opens the HTML video)

<html>
<body>
<script>
    var windowWidth = 400;
    var windowHeight = 200;
    var xPos = (screen.width/2) - (windowWidth/2);
    var yPos = (screen.height/2) - (windowHeight/2);
    window.open("popup.html","POPUP","width=" 
    + windowWidth+",height="+windowHeight +",left="+xPos+",top="+yPos);
</script>
</body>
</html>

File two (video that closes the assistant)

<html>
<body onload="window.opener.close();">
</body>
</html>
+5
source

With his help:

<script language="javascript">

  function resizeVideoPage(){
    var width = 600;
    var height = 400;
    window.resizeTo(width, height);
    window.moveTo(((screen.width - width) / 2), ((screen.height - height) / 2));      
  }
</script>

// Then...

<body onload="resizeVideoPage();"></body>
+9
source

All Articles