Flash! Ahaaa! He saved every one of us...
Andy Wardley
abw at wardley.org
Tue May 6 11:21:51 BST 2008
Lyle wrote:
> If you've got javascript turned on it's flash the first time you visit.
> Then a png after that, until 24 hours later when you get to see the
> flash once again. The site is still an early draft and subject to much
> change.
Hmm, strange. It was definitely a .png the first time I looked. I just
tried again, and then I got the flash. Now I just get the .png again.
(looks at source).
Ah yes, your code is subtly broken. You've got a race condition.
You do this in the main document:
document.write(input)
But this can be (and in my case probably was) executed before your
js/cookie.js has finished loading, executing and defining the input
variable.
You should look at using something like jQuery for things like this.
<!-- define an empty header -->
<div id="header"></div>
<!-- load jQuery library -->
<script type="text/javascript" src="jquery.js"></script>
<!-- define a function to replace the header content when the
document has finished loading -->
<script type="text/javascript">
$(document).ready( function() {
$('#header').html(input);
});
</script>
HTH
A
More information about the london.pm
mailing list