Forum Moderators: open

Message Too Old, No Replies

"Break out" of refreshing div issue

         

gnetcon

2:36 am on Sep 9, 2009 (gmt 0)

10+ Year Member



All:

I have a script that simply refreshes the content of a certain div every few seconds using javascript.

My problem is that when a user, say, is logged out, the entire login page (with menu and all) displays within the contents of that div.

How can I programatically refresh the entire page, when needed? I tried the very basic top.location.href, but it doesn't work.

Any ideas would be greatly appreciated!

TIA!

whoisgregg

2:20 pm on Sep 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you setting any cookies when the user is logged in or logged out? If so, you could use javascript to read those cookies and branch based on their values/existence.

Also, instead of your script returning a login page, perhaps you could have it return a javascript value (like "false") so you can branch based on that.

gnetcon

12:20 pm on Sep 10, 2009 (gmt 0)

10+ Year Member



whoisgregg:

No cookies, no.

I think my best bet is to set a session value in PHP when the user is logged out. I can then check for this value in the application. I just need to know:

If it IS found, how can I make sure that I reload the full page, and not just the div that the chosen code may be updating?

gnetcon

1:42 pm on Sep 10, 2009 (gmt 0)

10+ Year Member



Actually, I figured it out.

In each call to refresh the div, a certain URL variable was passed. I then check that against the session value, and if it has changed, and the URL value exists, I don't display the header/footer. Just the box. If it doesn't exist, I display the whole page.

No JavaScript needed. : )

vol7ron

1:46 pm on Sep 10, 2009 (gmt 0)

10+ Year Member



I read this and found it interesting. I don't clearly understand it though. Could you describe it again in a little more detail?

1) You have a web page
2) There is a DIV on that page that refreshes (let's say it's sports scores)
3) When logging in/out that DIV is being replaced with the page body?

Why not start/stop your timer when logging in/out?

If that's not what's going on, maybe your follow-up will help clarify what I am confused about.

gnetcon

1:57 pm on Sep 10, 2009 (gmt 0)

10+ Year Member



vol7ron:

You have the process correct. I couldn't stop the timer, because it also controls/updates other areas (divs) that don't require a user to be logged in.

My way prolly isn't the best way, but it's working now. It doesn't actuallu display a login box, just a message that you need to be logged in to see it. My problem was the message was including the full web page, instead of just the box. On other pages, I needed it to display the whole page (menu, navigation, etc).

So now I look to see if that particular URL variable is passed. If it is, I know I'm in a div, so just display the message. Otherwise, I display everything.

Clear as mud? : )