Javasctript, IE, Chrome, Firefox
say("The page is loading!");
<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?
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 ?
Yeah, it sounds like a caching issue.
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.
yeah ok, thanks for your replies.
I will give it a go without the visual studio. I will let you know what happens.
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?
Thanks for all your help.
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.
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!
Thanks for your support.