Этот сайт имеет ограниченную функциональность, пока мы проводим техническое обслуживание для улучшения его работы. Если какая-либо статья не решила вашу проблему и вы хотите задать вопрос, наше сообщество поддержки ждёт вас: @FirefoxSupport в Твиттере и /r/firefox на Reddit.

Поиск в Поддержке

Избегайте мошенников, выдающих себя за службу поддержки. Мы никогда не попросим вас позвонить, отправить текстовое сообщение или поделиться личной информацией. Сообщайте о подозрительной активности, используя функцию «Пожаловаться».

Подробнее

Developers console saying function is "undefined" but the function runs fine

  • 5 ответов
  • 1 имеет эту проблему
  • 66 просмотров
  • Последний ответ от finitarry

more options

I'm a web developer, and I've been working on creating a site ( http://mythicalslab.x10host.com/ ). On the site I have some javascript that handles displaying a div with a loading animation on it. In script html tags, I have two function defined, hideLoading() and showLoading() which respectively show and hide the loading animation.

If I go into the Javascript console in Firefox, and either type hideLoading() or showLoading(), the console says "undefined", but it still runs the function correctly.

If you want to check this put for yourself, go to my homepage ( http://mythicalslab.x10host.com/ ) and type showLoading() in the dev console, and you'll see it will run the function and show the loading animation, while saying it is undefined.

I'm a web developer, and I've been working on creating a site ( http://mythicalslab.x10host.com/ ). On the site I have some javascript that handles displaying a div with a loading animation on it. In script html tags, I have two function defined, hideLoading() and showLoading() which respectively show and hide the loading animation. If I go into the Javascript console in Firefox, and either type hideLoading() or showLoading(), the console says "undefined", but it still runs the function correctly. If you want to check this put for yourself, go to my homepage ( http://mythicalslab.x10host.com/ ) and type showLoading() in the dev console, and you'll see it will run the function and show the loading animation, while saying it is undefined.

Изменено Mythical

Выбранное решение

Undefined is about the return value of a function call. You only see something useful when a function returns value. If nothing is returned then you see undefined.

  • (function (){return("OK")})()
  • (function (){})()
Прочитайте этот ответ в контексте 👍 1

Все ответы (5)

more options

http://mythicalslab.x10host.com/ I do not see any textbox on that page at all. I accessed the page with two completely different browsers. Where is this dev console?

more options

Выбранное решение

Undefined is about the return value of a function call. You only see something useful when a function returns value. If nothing is returned then you see undefined.

  • (function (){return("OK")})()
  • (function (){})()

Изменено cor-el

more options

cor-el said

Undefined is about the return value of a function call. You only see something useful when a function returns value. If nothing is returned then you see undefined.
  • (function (){return("OK")})()
  • (function (){})()

Oooh, okay, I thought it was saying whether the console ran the function correctly or not.

more options

finitarry said

http://mythicalslab.x10host.com/ I do not see any textbox on that page at all. I accessed the page with two completely different browsers. Where is this dev console?

I'm talking about the developers console built-into Firefox in the developer tools window.

more options

Right, I forgot about that. I do not use that very often. I see a lot of complaints about graphical settings such as: Expected declaration but found '/'.