Results 1 to 3 of 3

Thread: image not loading

  1. #1
    Join Date
    Dec 2009
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question image not loading

    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.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    <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>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    cocag (12-11-2009)

  4. #3
    Join Date
    Dec 2009
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    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
    Last edited by cocag; 12-11-2009 at 01:13 PM. Reason: updated info

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •