Forum Moderators: open

Message Too Old, No Replies

Refresh an element in Javascript

Not working in IE

         

marciano

11:30 pm on Nov 14, 2011 (gmt 0)

10+ Year Member




To better explain my issue I'll ask you to check it by yourself, if possible.[stonek.com ]
This is a page with photo thumbnails.
There's a "Remember this photo" checkbox near each one.
Click on a thumbnail to open a popup window with a larger image. It also contains a checkbox.
Do not close the popup and go to referred page.
Check the correspondent thumbnail. (photo # is added to a cookie string)
All main browsers also check the regular photo in opened popup window because of refreshing checkbox script I detail next, but IE does not.

This is the script that refreshes the checkbox state

function updateDiv(){
var ord = getCookie('ordinals'); //string containing all checked images
if( ord.indexOf("<?=$ordinal?>")==-1 ){
document.getElementById("chk<?=$ordinal?>").checked=false //not checked
}
else {
document.getElementById("chk<?=$ordinal?>").checked=true//checked
}
$('chk<?=$ordinal?>').html(newContent);
}

setInterval('updateDiv()', 1000); // that's 1 second
......
......
<body onload="updateDiv(); ....

Thanks for help.
PS: popup checks work fine in all browsers (no refresh is needed, just referred page element), referred main page does change the checkbox state.

penders

8:41 am on Nov 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It appears to work OK-ish for me in IE8 (the underlying checkbox in the main window is also checked), however, I do get some JavaScript errors reported:

When page loads:
- Object doesn't support this property or method
index_resultados_en.php - line 84 - char 1

When popup opens (reported twice) - only the first time the popup opens:
- 'undefined' is null or not an object
resultado_en.php - line 42 - char 1

When popup opens (reported twice) - on subsequent times when popup opens:
- 'newContent' is undefined
.../resultado_en.php?ordinal=21794&nav=MSIE - line 52 - char 1

Firefox also gives some errors, but otherwise appears to work OK...

- too much recursion
.../JS/jQuery.js

- newContent is not defined
resultado_en.php?ordinal=21794

(btw, I clicked on the chicken!)

marciano

7:10 pm on Nov 15, 2011 (gmt 0)

10+ Year Member



Hi Penders, thanks for your reply.

It appears to work OK-ish for me in IE8 (the underlying checkbox in the main window is also checked),

This is (was) not the issue. Check the underlying checkbox and see that popup checkbox does not change (did not). Reverse procedure works fine.

I am not familiar with Windows environment. I am testing in Win7 IE9 under VMWare.

I fixed JS errors, I guess. IE works as expected too

function updateDiv(){ // usa jQuery
var ord = getCookie("ordinales");
if (ord != null && ord != ""){ // si existe la cookie
if( ord.indexOf("<?=$ordinal?>")==-1 ){ // si el ordinal está en la cookie
 document.getElementById("chk<?=$ordinal?>").checked=false//no checked
}
else {
document.getElementById("chk<?=$ordinal?>").checked=true//checked
}
}
}

Can you please check if you see any other errors but 'recursion'.
To not to mess the things up I'll start another thread about this jQuery issue.
Thank you

penders

11:38 pm on Nov 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This is (was) not the issue. Check the underlying checkbox and see that popup checkbox does not change (did not). Reverse procedure works fine.


Sorry, yes, I was checking the 'reverse procedure' - my bad. And yes, it all appears to work OK in IE8 (WinXP) - both ways. No JavaScript errors.

I don't get the jQuery 'recursion' error in Firefox anymore either. Did you have to do something specific to resolve that?

The only error I do seem to get is related to ads (in Firefox 3.6):
Error: Permission denied for <http://googleads.g.doubleclick.net> to call method Location.toString

marciano

1:38 am on Nov 16, 2011 (gmt 0)

10+ Year Member



Hi Penders,
The recursion error was because of using fade with jQuery.
I removed that fading text and looking for a clean way.
(alternate title fading between two txt)
I don't understand that error from google adsense.
I also have seen it in Mac Chrome "Unable to post message to [googleads.g.........]
In FF 7.0.1 on Linux and Firebug I don't get this error.
Thanks!