Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #8843

Re: Browser crashes with below code.What is wrong in below code.

From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.javascript
Subject Re: Browser crashes with below code.What is wrong in below code.
Date 2011-12-04 15:04 +0100
Organization A noiseless patient Spider
Message-ID <4EDB7DE3.4030802@arnowelzel.de> (permalink)
References <6797273.191.1322974644678.JavaMail.geo-discussion-forums@yqnq37> <347605.1116.1322974969697.JavaMail.geo-discussion-forums@yqcm37>

Show all headers | View raw


kiran, 2011-12-04 06:02:

> This is code which crashes browsers,below code do not have end UL tag.Though having end UL fixes the crash,but wanted to get this confirmed.
> 
> <!DOCTYPE HTML> 
> <html> 
> <head> 
> <meta charset="utf-8"> 
> <title>Simple Test Case</title> 
> </head> 
> 
> <body> 
> <ul> 
> <li>Test1</li> 
> <li>Test2</li> 
> <li>Test3</li> 
> <li>Test4</li> 
> <li>Test5</li> 
> <li>Test6</li> 
> 
> 
> <script type="text/javascript" src="js/jquery-1.6.4.js"></script> 
> <script> 
> jQuery('ul').clone().appendTo('body'); 
> </script> 
> </body> 
> </html>

Confirmed.

I assume the problem is caused by the missing end tag for the list,
since list is then not closed yet.

clone() will collect existing elements. appendTo() will then append
thoes elements. I did not have a look to the code of jquery, but i
assume clone() will also see those elements which get created by appendTo().

So this it what happens:

- clone() will fetch "Test1"
- appendTo() will create a copy of "Test1" and the end of the list
- clone() will fetch "Test2"
- appendTo() will create a copy of "Test2" and the end of the list
...
- clone() will fetch "Test6"
- appendTo() will create a copy of "Test6" and the end of the list

and NOW clone() will see the first copy of "Test1" since the list is not
closed by </ul> - therefore the whole process continues until the
browser crashes. Well - at least my FF 8.0.1 asks me after a while if i
want to stop the script ;-)



-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Browser crashes with below code.What is wrong in below code. kiran <kiranmbadi@gmail.com> - 2011-12-03 20:57 -0800
  Re: Browser crashes with below code.What is wrong in below code. kiran <kiranmbadi@gmail.com> - 2011-12-03 21:02 -0800
    Re: Browser crashes with below code.What is wrong in below code. Swifty <steve.j.swift@gmail.com> - 2011-12-04 06:52 +0000
      Re: Browser crashes with below code.What is wrong in below code. RobG <rgqld@iinet.net.au> - 2011-12-04 02:41 -0800
    Re: Browser crashes with below code.What is wrong in below code. Arno Welzel <usenet@arnowelzel.de> - 2011-12-04 15:04 +0100
      Re: Browser crashes with below code.What is wrong in below code. RobG <rgqld@iinet.net.au> - 2011-12-04 16:29 -0800
        Re: Browser crashes with below code.What is wrong in below code. kiran <kiranmbadi@gmail.com> - 2011-12-05 07:06 -0800
          Re: Browser crashes with below code.What is wrong in below code. RobG <rgqld@iinet.net.au> - 2011-12-05 17:49 -0800
            Re: Browser crashes with below code.What is wrong in below code. Scott Sauyet <scott.sauyet@gmail.com> - 2011-12-06 05:04 -0800
              Re: Browser crashes with below code.What is wrong in below code. kiran <kiranmbadi@gmail.com> - 2011-12-06 16:37 -0800
                Re: Browser crashes with below code.What is wrong in below code. "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-12-07 08:45 +0000
              Re: Browser crashes with below code.What is wrong in below code. RobG <rgqld@iinet.net.au> - 2011-12-07 04:45 -0800
                Re: Browser crashes with below code.What is wrong in below code. Scott Sauyet <scott.sauyet@gmail.com> - 2011-12-07 06:38 -0800

csiph-web