Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 08-04-2011, 09:23 PM Odd Question
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
I'm a complete JS noob, but I know a few things about it. I know that the following used to work in Firefox, but now it doesn't.

HTML Code:
<script type="text/javascript">
function change() {
document.getElementById('helloworld').innerHTML='Goodbye, World!';
}
window.onload=change;
</script>
<div id="helloworld">
Hello, World!
</div>
But for some odd reason now, it doesn't. Does anybody know why this is? I'm not sure exactly when it stopped working, I just noticed it when I set out to make a little counter script.

Thanks,

-PG
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-04-2011, 10:39 PM Re: Odd Question
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Is this loaded after the onload event is triggered?
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-05-2011, 12:36 PM Re: Odd Question
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
That could be it, but I don't think so. I just remember having this code in one of my previous projects, and it worked fine.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 08-05-2011, 01:11 PM Re: Odd Question
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Any errors displayed in FF error console?
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-05-2011, 02:07 PM Re: Odd Question
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Quote:
Originally Posted by mgraphic View Post
Any errors displayed in FF error console?
Hmm, nope! This is really weird.

I tried something else, and I found out that if you put the JS code inside an external .js file, and link to it with <script src="..."></script>, it works just fine.

No errors on that, either.

EDIT: Now the example I used above is working fine in FF. It changed overnight?
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!

Last edited by Physicsguy; 08-05-2011 at 02:08 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 08-05-2011, 06:32 PM Re: Odd Question
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Perhaps you were viewing a cached version of your example page, that wasn't correct?
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 08-05-2011, 09:45 PM Re: Odd Question
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
No, I have Web Developer tools, and have cache disabled on every website I've ever been to. I even tried a hard refresh (Ctrl-F5), and that did nothing.

Although it works now so I guess this thread is sort of useless unless (:O) somebody else has a similar issue...
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 08-08-2011, 09:19 AM Re: Odd Question
Extreme Talker

Posts: 246
Trades: 0
My thought is since the original code was not in the head that the following happened:

1. The page loads and causes the onload event to fire prior to reaching your JS code.
2. Your JS code loads
3. Your JS code doesn't run since the onload event has already fired which also means no errors.
4. Now that you have your code in an external file, the onload event gets bound and will fire when the page loads (since the reference is in the head tag).

This is just my hypothesis.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Old 08-10-2011, 02:48 AM Re: Odd Question
Novice Talker

Posts: 12
Name: Teodorescu Mihail
Location: Romania
Trades: 0
did you try this :
Code:
<script language="javascript" type="text/javascript">
?
Sonic3R is offline
Reply With Quote
View Public Profile
 
Old 08-10-2011, 08:51 AM Re: Odd Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
There is no languange attribute for the script element.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-10-2011, 09:02 AM Re: Odd Question
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
No guys, the problem is solved. It turns out that I needed to call the JS AFTER the div call, so the div would be initialized before the JS.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 08-11-2011, 04:20 AM Re: Odd Question
Novice Talker

Posts: 12
Name: Teodorescu Mihail
Location: Romania
Trades: 0
the script must be placed between <head> </head> tag
and div between <body></body> tag
Sonic3R is offline
Reply With Quote
View Public Profile
 
Old 08-11-2011, 04:53 AM Re: Odd Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Sonic3R View Post
the script must be placed between <head> </head> tag
and div between <body></body> tag
Now had you read the post before yours you would KNOW that your suggestion would NOT work at all.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Odd Question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.56089 seconds with 12 queries