PDA

View Full Version : image not loading



cocag
12-11-2009, 06:12 AM
Howdy,

I know this is a basic ques, but thats what us newbies do <g>

How come this won't load the large image "AUS_large.jpg" after the page "Bottom1.html" loads in the bottom frame?


INDEX.HTML
<frameset rows="200,200" frameborder="YES" framespacing="0">
<frame src="top.html" name="topFrame" id="topFrame">
<frame src="bottom.html" name="bottomFrame" id="bottomFrame">
</frameset>

TOP.HTML
<script language="JavaScript">
function ShowPic(){
parent.bottomFrame.location.href ="bottom1.html"
parent.bottomFrame.pic.src="AUS_large.jpg"}
</script>
</head>
<body>
<img src="AUS_small.JPG"
onclick="ShowPic()">
</body>

BOTTOM.HTML
<body>
nothing here
</body>

BOTTOM1.HTML
<body>
<img ID="pic" src="AUS_small.JPG">
</body>

Thankyou in advance. ;)

jscheuer1
12-11-2009, 06:48 AM
I don't think you can access an element by its id that way. Besides, even if you could, the script executes almost immediately. Even with all pages local, it takes a little longer for the bottom1.html to load. So the image tag isn't there yet. This works here for top.html:


<script type="text/javascript">
function showPic(){
parent.bottomFrame.location.href = "bottom1.html";
showPic.show();
}
showPic.show = function(){
if(parent.bottomFrame.document.getElementById('pic')){
parent.bottomFrame.document.getElementById('pic').src="AUS_large.jpg";
}else{
setTimeout(showPic.show, 300);
}
}
</script>
</head>
<body>
<img src="AUS_small.JPG"
onclick="showPic();">
</body>

cocag
12-11-2009, 10:03 AM
Excellant, thanks for your quick reply bud ;o))

This works fine (after fine tuning) untill I click on the link in

TOP.HTML
<body>
<img src="AUS_small.JPG"
onclick="showPic();">
</body>

a second time, then it just loads/shows the

BOTTOM1.HTML
<body>
<img ID="pic" src="AUS_small.JPG">
</body>

and doesn't load the AUS_large.JPG again.


Anyway easy way of checking if the BOTTOM1.HTML is loaded first, if this is even a good way around it?


Thanks