0

I wrote this simple code, that should repeatedly open google.com, and close it.

However, the code only appears to run once. How can I fix this code?

I apologize for this newbie mistake. I am new to JavaScript programming.


Here is my code:

<html> 
  
<body> 
  
<p>Click the button to eat your RAM</p> 
  
<button onclick="start()"> 
Start Opening Site
</button> 
  


<script> 

function OpenNewTab() { 
window.open("https://www.google.com/", "_blank"); 
}

function CloseNewTab() {
openedWindow.close();
}


function start() {
setInterval(OpenNewTab(), 200);
setInterval(CloseNewTab(), 300);
}



    

</script> 
  
</body> 
  
</html>

1 Answers1

0

You just have to write

setInterval(CloseNewTab, 300);
Aalexander
  • 4,987
  • 3
  • 11
  • 34