Joe[y]
05-03-2006, 07:07 PM
so it's not often that i ask for help here but i'm not much of a DOM person and i could really do with some help on this topic. basically i'm tryingto teach myself how the innerHTML statement works - here's my story:
i'm using moo fx at http://photos.jlspurling.com to do a fade effect on my photos when a page loads. anyway, because moofx only kicks in once the page is fully loaded the photo appears and then once it is loaded disappears briefly before fading in again - this is just ugly. what i want is to not see the photo while it is loading. i figured the best way to do this was to not have the code showing at all until the javascript on the page kicks in (as this is all client side). soooo... i was recommended the innerHTML trick to basically insert the picture into an element with javascript. so here's the code to help break this down:
i currently have:
<script type="text/javascript">
window.onload = function() {
imageinfoReveal = new fx.Height('imagecontent', {duration: 600});
imageinfoReveal.hide();
imageReveal = new fx.Opacity('photo', {duration: 1500});
imageReveal.custom(0, 1)
}
</script>
which works fine for everything moofx wise apart from the problem above. so i need to include the innerHTML thing for window.onload too:
<script type="text/javascript">
window.onload = function() {
imageinfoReveal = new fx.Height('imagecontent', {duration: 600});
imageinfoReveal.hide();
imageReveal = new fx.Opacity('photo', {duration: 1500});
imageReveal.custom(0, 1)
getElementById("image").innerHTML = "<a href=\"'#\"><img src=\"photo.jpg\" id=\"photo\" /></a>"
}
</script>
as far as i'm aware this should insert the html into <div id="image"></div> in my template files. i'm sure this is absolutely rubbish on my part but i honestly have no clue what i'm doing - can anybody shed any light on why this isn't working or possibly offer me a solution?
hope that all made sense!
i'm using moo fx at http://photos.jlspurling.com to do a fade effect on my photos when a page loads. anyway, because moofx only kicks in once the page is fully loaded the photo appears and then once it is loaded disappears briefly before fading in again - this is just ugly. what i want is to not see the photo while it is loading. i figured the best way to do this was to not have the code showing at all until the javascript on the page kicks in (as this is all client side). soooo... i was recommended the innerHTML trick to basically insert the picture into an element with javascript. so here's the code to help break this down:
i currently have:
<script type="text/javascript">
window.onload = function() {
imageinfoReveal = new fx.Height('imagecontent', {duration: 600});
imageinfoReveal.hide();
imageReveal = new fx.Opacity('photo', {duration: 1500});
imageReveal.custom(0, 1)
}
</script>
which works fine for everything moofx wise apart from the problem above. so i need to include the innerHTML thing for window.onload too:
<script type="text/javascript">
window.onload = function() {
imageinfoReveal = new fx.Height('imagecontent', {duration: 600});
imageinfoReveal.hide();
imageReveal = new fx.Opacity('photo', {duration: 1500});
imageReveal.custom(0, 1)
getElementById("image").innerHTML = "<a href=\"'#\"><img src=\"photo.jpg\" id=\"photo\" /></a>"
}
</script>
as far as i'm aware this should insert the html into <div id="image"></div> in my template files. i'm sure this is absolutely rubbish on my part but i honestly have no clue what i'm doing - can anybody shed any light on why this isn't working or possibly offer me a solution?
hope that all made sense!