Forum Moderators: open

Message Too Old, No Replies

Javascript error "Expected object"

Trying to reload page

         

runner

4:24 am on Nov 27, 2004 (gmt 0)

10+ Year Member



I have a small javascript function that reloads the current page as the last command. No matter what method I use to try to get the page to reload, I always get an "object expected" error. Everything else works fine.

I tried reloading the page using two different methods: history.go and location.reload. Both lines produce "object expected" errors. I'm new to javascript so I don't know what is wrong.

function increment()
{
var currentMonth = int(readCookie('month'))+1;
createCookie('month',currentMonth,7);
history.go(0);
}

function decrement()
{
var currentMonth = int(readCookie('month'))-1;
createCookie('month',currentMonth,7);
location.reload();
}

Bernard Marx

9:17 am on Nov 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just asking, since you're new n'all..

Have the functions int, and createCookie been defined?

The Javascript function for parsing strings to integers is

parseInt(string[,base]) // best to use explicit base 10

Welcome to WebmasterWorld (and Javascript).

runner

5:14 pm on Nov 27, 2004 (gmt 0)

10+ Year Member



The other functions already exist and work fine. However, I am going to use the parse integer function you described.

runner

5:25 pm on Nov 27, 2004 (gmt 0)

10+ Year Member



I changed my integer function and everything works just fine. It even fixed the problwm with the page refresh not working. Thanks!

Bernard Marx

5:29 pm on Nov 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nice