cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript not working in Firefox on Mac OS 10.9.2

SOLVED
Highlighted
New User

Javascript not working in Firefox on Mac OS 10.9.2

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Site Moderator

Re: Javascript not working in Firefox on Mac OS 10.9.2

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

13 REPLIES
SUMO Contributor

Re: Javascript not working in Firefox on Mac OS 10.9.2

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?

New User

Re: Javascript not working in Firefox on Mac OS 10.9.2

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

SUMO Contributor

Re: Javascript not working in Firefox on Mac OS 10.9.2

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.

New User

Re: Javascript not working in Firefox on Mac OS 10.9.2

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);

New User

Re: Javascript not working in Firefox on Mac OS 10.9.2

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!

SUMO Contributor

Re: Javascript not working in Firefox on Mac OS 10.9.2

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.

SUMO Contributor

Re: Javascript not working in Firefox on Mac OS 10.9.2

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.

New User

Re: Javascript not working in Firefox on Mac OS 10.9.2

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...

SUMO Contributor

Re: Javascript not working in Firefox on Mac OS 10.9.2

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>