Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-21-2010, 11:27 AM   PM User | #1
ta_4_me
New Coder

 
Join Date: Mar 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ta_4_me is an unknown quantity at this point
body onload setinterval

I found a little chat script online and I wanted to check it out. When I integrated it into a page I created, for some reason this will not work correctly

<body onload="setInterval('chat.update()', 1000)">

I tested it with two different browswers open

Lets say on two different browser windows you have user1 and user2

if user1 types 'Hello'
it will not show up on user2 window
but if user2 types 'Hi'

then on user2 window it will say
user1 says Hello
user2 says Hi

so basically for user1 to see what user2 has wrote, user1 has to type something first and send it to see what user2 said.

hope you understand, if you would like I could post up the code.
ta_4_me is offline   Reply With Quote
Old 03-21-2010, 11:46 AM   PM User | #2
ta_4_me
New Coder

 
Join Date: Mar 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ta_4_me is an unknown quantity at this point
I forgot to say that on the original script, within the body tags, there was no PHP code. But on my page, i have php within the body tags, does have anything to do with it?
ta_4_me is offline   Reply With Quote
Old 03-21-2010, 11:54 AM   PM User | #3
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
chat.update is not a valid name for a function (may not contain a dot).
Change it to chat_update.



All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
Philip M is offline   Reply With Quote
Old 03-21-2010, 11:55 AM   PM User | #4
ta_4_me
New Coder

 
Join Date: Mar 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ta_4_me is an unknown quantity at this point
actually i got rid of the body onload and used a window onload js function and everything seems to be ok now.
ta_4_me is offline   Reply With Quote
Old 03-21-2010, 11:56 AM   PM User | #5
ta_4_me
New Coder

 
Join Date: Mar 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ta_4_me is an unknown quantity at this point
Here is what the was for

function Chat () {
this.update = updateChat;
this.send = sendChat;
this.getState = getStateOfChat;
}
ta_4_me is offline   Reply With Quote
Old 03-21-2010, 04:37 PM   PM User | #6
mrhoo
Regular Coder

 
Join Date: Mar 2006
Posts: 708
Thanks: 30
Thanked 127 Times in 118 Posts
mrhoo will become famous soon enoughmrhoo will become famous soon enough
Your object was 'Chat.update', not the 'chat.update'-
and you really ought to allow for quitting any timed event,
by giving the timer a reference

Code:
onload= function(){
Chat.timer=setInterval(Chat.update, 1000);
}

//clearInterval(Chat.timer)
mrhoo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 09:37 AM.


Advertisement
Log in to turn off these ads.