Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Telefonnummer anzurufen, eine SMS an eine Telefonnummer zu senden oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Weitere Informationen

Javascript not working in Firefox on Mac OS 10.9.2

more options

I am trying to learn Javascript from a tutorial. I'm using Text edit to create a simple .html file that calls a .js file using the script command. The .html file opens normally in the default browser and can print a message to a simple page. It looks like a window tries to open the .js file but it vanishes before opening. I have checked that Javascript is enabled in Firefox. Opening Firefox in Safe mode does not fix the problem. It also fails to execute the .js file in Safari and Chrome.

This problem happens on three Macs, all running Mavericks 10.9.2. When I try this on a Windows PC the .js file executes as expected.

I've tried everything I can think of including turning off the Firewall in Security Settings. It seems like it has to be something system-wide since it happens in all three browsers. Has Apple implemented some type of blocking of Javascript in Mavericks? Any suggestions for why this is not working on my Macs and what I can do to fix it would be greatly appreciated!

I am trying to learn Javascript from a tutorial. I'm using Text edit to create a simple .html file that calls a .js file using the script command. The .html file opens normally in the default browser and can print a message to a simple page. It looks like a window tries to open the .js file but it vanishes before opening. I have checked that Javascript is enabled in Firefox. Opening Firefox in Safe mode does not fix the problem. It also fails to execute the .js file in Safari and Chrome. This problem happens on three Macs, all running Mavericks 10.9.2. When I try this on a Windows PC the .js file executes as expected. I've tried everything I can think of including turning off the Firewall in Security Settings. It seems like it has to be something system-wide since it happens in all three browsers. Has Apple implemented some type of blocking of Javascript in Mavericks? Any suggestions for why this is not working on my Macs and what I can do to fix it would be greatly appreciated!

Ausgewählte Lösung

Note that your alert and prompt code is using Unicode quotes (“Hello world”) and not normal quotes (")

Diese Antwort im Kontext lesen 👍 4

Alle Antworten (13)

more options

It's hard to troubleshoot without seeing the script, and it's rare that script which works on Windows wouldn't work on Mac...

When you say a window opens, do you mean a pop-up window (script method window.open())? Do your Macs have any security software installed that might suppress Firefox popups that your Windows PCs do not have?

more options

Hi jscher,

Here is the file container.html that will print "This is a simple page" in a blank page of Firefox. The next command should call the script.js file but it doesn't work on the Mac, only on the PC.

<html>
	<head>
		<title>Simple Page</title>
	</head>
	<body>
		<p>This is a simple page</p>
		<script src=“script.js”></script>
	</body>
</html>

Here is the content of the script.js file:

alert(“Hello world”);
var name = prompt(“What is your name?”);
alert(“Hello, “ + name);

Again, script.js gets called on the PC and executes as expected. On the Mac it looks like a window TRIES to open (starts to zoom out from the center of the page) but then fails to open a new window. I am not aware of any security software on the Mac that suppresses Firefox popups but I do recall that Firefox usually asks me if I want to allow a popup when a website tries to open one. In the case of my .js script I do not see an alert asking if I want to allow a popup.

Thanks for trying to help. Please let me know if this information provides any clue as to what is wrong.

Gene

Geändert am von cor-el

more options

There is a limit on the number of these modal dialogs (alert, prompt, confirm) that a site can show in a row without some user action in between. But I would expect Firefox on Mac to be the same as Firefox on Windows in that regard. Hopefully a Mac user will have more insight than I do.

more options

I just realized that the scripts did not copy/paste correctly. Here is container.html

<title>Simple Page</title>

This is a simple page

<script src="“script.js”"></script>

And here is script.js

alert(“Hello world”); var name = prompt(“What is your name?”); alert(“Hello, “ + name);

more options

Still not pasting correctly. The forum must be interpreting the text.

jscher: Thanks for taking a look. Let's hope a Mac genius can provide some insight here!

more options

Can you confirm that your script is running by adding a new first command. For example:

document.body.style.background = "#ffc"; // pale yellow page background

(To keep line breaks in your code when posting here, start each new line with a space.)

And you can check for error messages in Firefox's Browser Console. Either:

  • Command + Shift + j (Windows: Ctrl+Shift+j)
  • Tools menu > Web Developer > Browser Console

It often helps to click the clear button, switch back to your page and reload, then come back to the console to check for fresh messages.

more options

Not sure whether it's the forum or your code, but: can you set text edit not to substitute fancy / smart quotation marks for straight ones? Those may be causing problems for Firefox.

more options

jscher: Pasting in your first line did not change the behavior. No pale yellow background.

Does that mean the script.js file is not getting called? Still don't see why this works on a PC but not on a Mac...

more options

If the page background does not change, it sounds as though the file is not being executed.

Because the forum sometimes eats HTML, I'm not sure whether your posts accurately show the full page content. Could you try this:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test Page</title>
</head>
<body>
<p>Look for dialogs!</p>
<script type="text/javascript" src="script.js"></script> 
</body>
</html>
more options

Ausgewählte Lösung

Note that your alert and prompt code is using Unicode quotes (“Hello world”) and not normal quotes (")

more options

Cor-el: Thank you for noticing that! Turning off smart quotes in Textedit which I am using to create the scripts solved the problem. Everything working as expected now. I hope others using Mac OS 10.9.2 will benefit from this as well.

more options

I'm having somewhat of a similar problem, BUT....

I built a html5/JS animation (using Flash CS6) and put it online to test it. This animation plays perfectly in EVERY BROWSER, EXCEPT FIREFOX.

One weird thing though, if I right-click the offline html file and choose "open with > Firefox" it DOES play the animation.

I'm also working with OSX 10.9.2 but the exact same thing happens on Windows PC.

Why can't I get the online version to work, where's the difference? I need this animation to work on a website.

View the full source code and animation here: http://www.access.gr/attiki/test1.html

more options

Hi atar, I moved my reply to your new thread: html5 doesn't play online but DOES play offline.

Geändert am von jscher2000 - Support Volunteer