Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Dette websted vil have begrænset funktionalitet, mens vi gennemgår vedligeholdelse for at forbedre din oplevelse. Hvis en artikel ikke løser dit problem, og du vil stille et spørgsmål, har vi vores supportfællesskab, der venter på at hjælpe dig på @FirefoxSupport på Twitter og/r/firefox på Reddit.

Søg i Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Læs mere

Why is Date() constructor is unavailable in Firefox?

  • 5 svar
  • 1 har dette problem
  • 8 visninger
  • Seneste svar af cor-el

more options

Am using javascript in simple web app. Works fine in Chrome, but in Firefox the Date() object type does not work. Specifically, console.log(new Date()) prints "<unavailable>" on the browser console.

Am using javascript in simple web app. Works fine in Chrome, but in Firefox the Date() object type does not work. Specifically, console.log(new Date()) prints "<unavailable>" on the browser console.

Alle svar (5)

more options

Your code works in the Web Console* if I open it below this page.

<center></center>

Q: Does your app use any libraries that override or redefine the Date() constructor?


* You can open the Web Console in the lower part of the tab using either:

  • "3-bar" menu button > Web Developer > Web Console
  • (menu bar) Tools > Web Developer > Web Console
  • (Mac) Command+option/alt+k

Ref.

Ændret af jscher2000 - Support Volunteer den

more options

Does not work for me. Just to simplify things, I created a tiny example that demonstrates the problem. Specifically, I created a file containing

<!doctype html5>
<html>
<script>
console.log(new Date());
</script>
</body>
</html>

and opened it as a file. In chrome, this displays the current date/time on the console. In Firefox, it shows <unavailable> on the console. Does Firefox need something more in the script to make the Date object available?

Thanks,

Ændret af cor-el den

more options

Clarification to last post. The tool is removing a portion of the example file. I've been futzing around with this trying to get it to show the complete file contents, but have not figured out how to do that. So here is an explanation.

The file starts with a "doctype html5" tag, followed by an "html" tag and a "body" tag. Then comes the "script tag" and the console.log(new Date()). Then, closing versions of all tags, in the reverse order.

Hope that makes things clear.

Jon

more options

To post code here, you can replace < with &lt; so the wiki software doesn't eat your tags.

In this case, the Browser Console and the Web Console behave differently with

console.log(new Date());

The tab-specific Web Console gives you access to Date() as an object you can explore by clicking the gray triangle to the left. See my earlier screenshot. The global Browser Console does not for some reason, instead it shows "unavailable." But the Date() object is indeed instantiated. If you try

console.log(new Date().toString());

the two consoles will both display the results.

Ref.

Ændret af jscher2000 - Support Volunteer den

more options

I don't know whether a website can access to console if that is what you are doing (i.e. you use this code in a website) because a website is in a sandbox when multi-process is enabled.