Monday, December 4, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  7] [ 3]  / answers: 1 / hits: 24603  / 15 Years ago, mon, april 27, 2009, 12:00:00

Firebug is reporting a return not in function error with no location (well, line 1 of nothing). How can I track down the source of this error?

return not in function
[Break on this error] return(0)
javascript:return... (line 1)

I'm running FireBug 1.05 on FF on Ubuntu.

I found a solution that works (for this configuration):

  var link = document.createElement('a');
if (childSummary.more) {
link.onclick = capture(function(id) { follow(id); },;
} else {
link.onclick = capture(function(id) { show(id); },;


function capture(fn, val) {
return function() { fn(val); return false; };

The code was in a loop in which the id was changing, necessitating the capture function.

Formerly the href was 'javascript: return 0' and the capture function wasn't returning false directly, instead using the result of the fn, and there was a path when it was returning the equivalent of true. The href was being evaluated causing the error.

Defining href as '#' or '' caused all the links to appear as already visited. Not defining href at all caused there to be no link highlighting. This seemed simplest.

More From » firebug


I think the javascript:return ... is telling. I believe you're trying to return a value in the href attribute of an anchor, as below:

<a href=javascript: return false>Test</a>

The reason Firebug isn't telling you the location is because it's not in any JavaScript, but is rather in a one-liner in the DOM.

[#99639] Wednesday, April 22, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 224
Total Questions: 89
Total Answers: 99

Location: Bahrain
Member since Fri, Sep 16, 2022
1 Year ago