Closed Bug 304579 Opened 19 years ago Closed 19 years ago

(javascript) after calling a function with onload, I can't recall it.

Categories

(Core :: JavaScript Engine, defect)

1.0 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: h4writer, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.9) Gecko/20050711 Firefox/1.0.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.9) Gecko/20050711 Firefox/1.0.5

I've made a page like this:
<script>
window.onload = function(){test(doc)}
function doc(){ 
alert('test');
doc(); // here you get an error, the function 'test' doesn't exist
}
</script>

but if I don't use a onload event, it works al fine (infinite loop)
<script>
function doc(){ 
alert('test');
doc(); // no error
}
test(doc);
</script>

There is a small workaround, just put on the end of your html
<script>test()</script>, but it works before everything is loaded.

Reproducible: Always

Actual Results:  
error in Javascript Console

Expected Results:  
infinite loop

This is my first bug and I don't know if the bug need to be here or in
Javascript Console bugs.
I've also searched after the bug and didn't found similary to this.
I don't quite understand what you're trying to do here. Where is there a
function 'test'? AFAIK, test is a builtin method, but only for RegExp. Please
attach a testcase to this bug that shows the problem.
Component: General → JavaScript Engine
Product: Firefox → Core
Version: unspecified → 1.0 Branch
Attached file testcase
I've add this as testcase, normally when you click the 'onclick method
(onclick="addition()")' you need to see 0 1 2 3 4 5 6 7 8 9 10,
but it shows only 0 and gives an error
Summary: (javascript) after calling a function with onload, I can recall it. → (javascript) after calling a function with onload, I can't recall it.
(In reply to comment #0)
> User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.9)
Gecko/20050711 Firefox/1.0.5
> Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.9)
Gecko/20050711 Firefox/1.0.5
> 
> I've made a page like this:
> <script>
> window.onload = function(){test(doc)}
> function doc(){ 
> alert('test');
> doc(); // here you get an error, the function 'test' doesn't exist
> }
> </script>
> 
> but if I don't use a onload event, it works al fine (infinite loop)
> <script>
> function doc(){ 
> alert('test');
> doc(); // no error
> }
> test(doc);
> </script>
> 
> There is a small workaround, just put on the end of your html
> <script>test()</script>, but it works before everything is loaded.
> 
> Reproducible: Always
> 
> Actual Results:  
> error in Javascript Console
> 
> Expected Results:  
> infinite loop
> 
> This is my first bug and I don't know if the bug need to be here or in
> Javascript Console bugs.
> I've also searched after the bug and didn't found similary to this.

Sorry I've made a couple of errors:
the script is:
<script>
function doc(){ 
  alert('test');
  doc(); // here you get an error, the function 'doc' doesn't exist
}
</script>
<body onload='doc()'>
WFM Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20050813
Firefox/1.0+ ID:2005081309

I see the desired output (1 through 10).

Can you try your testcase in a current nightly build?
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/

I recommend using a clean profile when you test with a recent trunk build.
(In reply to comment #4)
> WFM Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20050813
> Firefox/1.0+ ID:2005081309
> 
> I see the desired output (1 through 10).
> 
> Can you try your testcase in a current nightly build?
> ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/
> 
> I recommend using a clean profile when you test with a recent trunk build.

yes it works good in Deer Park,
but I have another problem, how can I make a clean profile?
because something wrong with the tabs now
To create a clean profile...

If firefox is in your system path, then just run firefox.exe -ProfileManager

If it's not, then use "path to firefox\firefox.exe" -ProfileManager

-->WORKSFORME per comment 5
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → WORKSFORME
(In reply to comment #6)
> To create a clean profile...
> 
> If firefox is in your system path, then just run firefox.exe -ProfileManager
> 
> If it's not, then use "path to firefox\firefox.exe" -ProfileManager
> 
> -->WORKSFORME per comment 5

thanks, I've tried it and now know it is due an extension my tabs where suckt up
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: