Im just learning javascript and want to make a code for a prank on my friend. I want it that when i plug in a certain usb it will pop up a fake virus alert after a couple of seconds, and when you exit off it will pull back up the alert a couple more seconds, and will keep doing it untill you take out the usb, but all i have is this.

    <button onclick="itsjustajokebro()">pop up</button> <script>
    function itsjustajokebro() {
      alert("Virus Alert");
    }   
</script> 
</body> 
</html>

My knowledge is limited and I need alot of help, like how to make it run with no button, and how to put it on usb.

That will take more than code. Today's Windows no longer autorun code when a stick or other media is plugged in.

Why? Because it became an all too easy infection vector.

i got more done on the code but cant make it loop

    ``<script>
    (function autorun()
    { 

        itsjustajokebro();

    })();
    function itsjustajokebro() {
  setTimeout(function(){ alert("Virus Alert"); }, 3000);
    }   
</script> 
</body> 
</html>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.