homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

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

Msg#: 4141572 posted 9:43 am on May 27, 2010 (gmt 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?




WebmasterWorld Senior Member 5+ Year Member

Msg#: 4141572 posted 2:12 pm on May 27, 2010 (gmt 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 ?


WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member

Msg#: 4141572 posted 2:21 pm on May 27, 2010 (gmt 0)

Yeah, it sounds like a caching issue.


5+ Year Member

Msg#: 4141572 posted 4:04 pm on May 27, 2010 (gmt 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.


Msg#: 4141572 posted 9:27 am on May 28, 2010 (gmt 0)

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



Msg#: 4141572 posted 9:34 am on May 28, 2010 (gmt 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?


Msg#: 4141572 posted 9:52 am on May 28, 2010 (gmt 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.



Msg#: 4141572 posted 7:25 pm on May 29, 2010 (gmt 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 :)


Msg#: 4141572 posted 11:50 pm on May 29, 2010 (gmt 0)

Thanks for your support.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved