Make an HTML page goto infinite loop?

1

Write a code using HTML, JavaScript, jQuery to make the page go into infinite loop.

Restrictions:

No looping or control structures of javascript and jQuery allowed. You can only use alert, events, etc.

Darshan Thanki

Posted 2012-10-03T08:27:46.663

Reputation: 21

Question was closed 2017-12-26T11:24:01.210

>

  • What's the winning condition? 2. What does it mean for a page to be in an infinite loop?
  • – Peter Taylor – 2012-10-03T08:37:44.903

    ok, Just edited the question including winning condition. – Darshan Thanki – 2012-10-03T08:42:27.627

    @grc: I'm not so sure it's ambiguous; a blank page doesn't require that the browser must be closed to continue. However, I don't think it's possible to do this in modern browsers. I'm not on Windows, but I can remember how to crash IE without using loops (though that may have been fixed in IE 9/10). – Andy E – 2012-10-03T09:21:26.783

    @Andy E: I don't really get what you mean by continue. Does it mean that you are able to use elements on the page, or that you are able to use other pages in the browser? – grc – 2012-10-03T09:32:21.000

    @grc: the OP makes it sound like he wants to lock up the browser and force it to be closed. This is difficult/impossible in browsers with sandboxed tabs, but you can crash a tab (see Florian's example). – Andy E – 2012-10-03T09:51:02.970

    I am a bit too busy to work on this at the moment, but my idea would be some form of frame-busting script that triggers when a frame is detected in some loop? might be possible? – NRGdallas – 2012-10-03T19:23:54.393

    That's not a winning criterion, because multiple players might achieve this goal. It could be the criterion to enter the contest. But a stable browser will only need to close a single tab. – user unknown – 2012-10-04T02:01:58.603

    ok @userunknown I removed the winning condition. Cheers! – Darshan Thanki – 2012-10-04T17:08:41.740

    @DarshanThanki: You shouldn't remove the winning criterion but modify it, because every question should have a winning criterion. – user unknown – 2012-10-04T19:17:50.673

    Answers

    8

    $($);
    

    May not meet your conditions, but I like it. (And it does crash your browser.)

    More information about this: Why does $($) crash my page?

    Florian Margaine

    Posted 2012-10-03T08:27:46.663

    Reputation: 286

    Yup, this locks up my tab in Chromium. – Andy E – 2012-10-03T09:51:47.787

    I see what you did there florian – ShrekOverflow – 2012-10-03T12:18:13.173

    @AndyE that locks up all browsers i have Safari , Opera , Chrome , Firefox , Aurora , Canary , RockMeIT , Maxathon ...... All hail jQuery .. they should put this as feature.!! Creates cross browser crashes :D – ShrekOverflow – 2012-10-03T12:19:16.450

    Little but awesome solution. I just thought of this one for the first time I came up with this question. Bravo, @florin – Darshan Thanki – 2012-10-03T12:55:14.817

    3

    How about a meta refresh?

    <meta http-equiv=refresh content=1>
    

    I removed the quotation marks around the parameter values because code golf.

    Darth Egregious

    Posted 2012-10-03T08:27:46.663

    Reputation: 277

    2

    This reloads the page as soon as it loads:

    <html>
    <head>
    <script>window.location=window.location</script>
    </head>
    </html>
    

    Or you could bring up infinite alert boxes (until the user disables them):

    <html>
    <body onfocus="alert('')"></body>
    </html>
    

    grc

    Posted 2012-10-03T08:27:46.663

    Reputation: 18 565

    5 years ago I would have voted on this. However, most modern browsers have a checkbox on the alert that will prevent further dialogs from appearing. – Andy E – 2012-10-03T08:47:29.693

    That's right. Even if you don't check it, the browser limits alerts to a specific number. Here is Google security policy that explains more about it.

    – Darshan Thanki – 2012-10-03T08:50:13.840

    @DarshanThanki That's the extension security policy... – Redwolf Programs – 2019-12-13T16:30:00.363

    2

    This will reload the browser indefinitely:

    location.reload()
    

    (Unless the browser specifically blocks repeated reloads.)

    Guffa

    Posted 2012-10-03T08:27:46.663

    Reputation: 121