Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

My javascript worked in IE and Chrome, but not Firefox.

Javasctript, IE, Chrome, Firefox

9:43 am on May 27, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 2, 2009
votes: 0


I'm doing an introductory javascript exercise on the msdn beginner's website. I'm using visual studio 2010, and here is the code.

<title>My page</title>
<script type="text/javascript" language="javascript">

function say(text)

say("The page is loading!");

JavaScript is turned off.

<input type="button" value="Click me!" onclick="say('Thanks for clicking!')" />


Well what happens in IE and Chrome, which is, I'm pretty sure the expected behaviour is this:
I right click on the document in visual studio and select "view in browser".
The browser displayes with a little message box with a button on it saying, "The page is loading!".
When I click this button the message box disappears and a button appears in the top left corner of the page. When I click on this button, a new message box appears that says, "Thanks for clicking!"

Well that's it, and that happens for CHrome and IE, but for firefox, when I change firefox to the default browser so I can use the "View in Browser" functionality of VS 2010, it works the first time. but every other time I try to do it in Firefox it just immediately goes to the page with the button in the top left-hand corner. I.e. the first message box with the "The page is loading!" message doesn't show.

Does anybody have an idea why I would get this different behaviour in Firefox?

2:12 pm on May 27, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
votes: 0

I guess Firefox says, I already have this page loaded and displayed, so save time and don't reload it. I have never used VS 2010, does it do the same thing not using VS 2010 ?
2:21 pm on May 27, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
votes: 10

Yeah, it sounds like a caching issue.
4:04 pm on May 27, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Feb 27, 2008
votes: 0

Instead of having a global function call, try adding it to the window's onload function.

1) change the body tag:
<body onload="say('The page is loading!');">

2) change the script
window.onload='say("The page is loading!")';

Note: there are other ways to attach events, but for this introductory course, the two above use the least advanced method.

The last Visual Studio I had was VS2005, and it's been a while since I've used it. So you know, there's a big difference from rendering the page w/in VS as Firefox, rather than opening the page directly in the Firefox browser. Certain events like these may be cached, or even bypassed.
9:27 am on May 28, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 2, 2009
votes: 0

yeah ok, thanks for your replies.
I will give it a go without the visual studio. I will let you know what happens.

9:34 am on May 28, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 2, 2009
posts: 68
votes: 0

Unfortunatly, it's doing the same thing outside of VS.
I just went into the windows file system and found the file and opened it with firefox.
Same result. So if it is a caching issue, is it fixable?
9:52 am on May 28, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 2, 2009
posts: 68
votes: 0

Hi, I played around with the cache by clearing it and I was getting some results, but it wasn't that consistent. I then saw that the browser toolbars were kind of loading in two stages. First the normal menus, and then the yahoo toolbar would load into the top of the browser. So I decided to uninstall that and see what happens, and now the browser works just like IE and Chrome for this javascript. I wonder how much this yahoo toolbar affects real javascript. Not sure if there is a way to fix this without installing this yahoo toolbar because I wouldn't want to be writing code that works on the condition that the user doesn't have yahoo toolbar installed on the browser.

Thanks for all your help.

7:25 pm on May 29, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:May 26, 2010
posts: 92
votes: 0


I placed your code in an HTML file on my desktop, dragged it into Firefox (version 3.6.3), and it works fine every time. Reloading displays the first alert() function call, and clicking the input button displays the second alert()

Personally, I never use toolbars except for the Firefox Web Developer Toolbar addon.

The Yahoo! toolbar blocks popups...which includes Javascript alert() boxes.

So, here's the quick & skinny: Most people don't want to see a Javascript alert() box pop up in their face when they first load a page...it's annoying.
For your exercise, it works...just trust that it does.
But, for the future, don't use alert() pop up messages that launch from the initial page load.
Many users have popup blockers (including the Y! toolbar)...and many people hate being greeted by a happy little alert box.

Just trust that your script works fine...good job for entry-level scripting!
Keep on writing Javascript my friend...it's a great language :)
11:50 pm on May 29, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 2, 2009
votes: 0

Thanks for your support.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members