homepage Welcome to WebmasterWorld Guest from 54.211.138.180
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Need to display image on load in an iframe
iframe image display
srikanthyadake




msg:4127532
 4:48 pm on May 5, 2010 (gmt 0)

Hi,
This is srikanth, newbie to this site.

I'm building a website for my college.

So i wannada display few images in random when user loads my home page.

figured out how to display random images using JavaScript, but could not put the images in an Iframe on loading...

wat to do?

And also IE 6 and firefox 3.5 not showing iframes instead showing in diff page itself

help!

Thanks

 

rocknbil




msg:4127641
 7:06 pm on May 5, 2010 (gmt 0)

Welcome aboard srikanthyadake, in a simplified version of your document (to reduce page length to the minimum that demonstrates the problem) post some code here to show what you have so far. Be sure to remove any identifying links or URL's per #13 of the TOS [webmasterworld.com]. This will help readers to suggest mods to your code to get where you want to go.

srikanthyadake




msg:4128065
 10:55 am on May 6, 2010 (gmt 0)

sure rocknbil,
here's the code part of iframe tag which im using in the main page(default) of my website

Between the iframe tag i need to put the images when user first loads my first page.

i have right now put image tag between this,tag ID being "random", is fetched by JavaScript function which i have put in the head section to display random images, but the images are not displayed as it is in b\w iframe tag, help!
<body>
<iframe id="fram" style="width:980px;height:400px;border:3px ridge;">
<img id="random" src="" alt=""/> <!-- not displaying as it is b\w iframe tag-->
</iframe>
</body>

can any thing be done with <body onload>?

Out of iframe tag it works fine.
Also firefox 3.6 not processing iframe tag! right now using chrome.

tedster




msg:4128303
 6:29 pm on May 6, 2010 (gmt 0)

How about placing the JavaScript on its own URL, and then use that URL as the iframe's src attrubte.

rocknbil




msg:4128547
 2:09 am on May 7, 2010 (gmt 0)

Right, OR

<iframe id="fram" style="width:980px;height:400px;border:3px ridge;" src="image-rotator.html"></iframe>

and move your Javascript and img src into "img-rotator.html."

However, I'm not undersanding why you need an iframe. Why can't you just put the image and the image's ID in place of the iframe, then use Javascript to change the image .src? I don't have time to chase down a full example, but


<img id="random" src="the-first-image-that-loads.jpg" alt=""/>

Then in your Javascript, you probably have an array which is a list of images. As you cycle through,

document.getElementById('random').src=images[j];

where "images" is the name of the array, j is the counter.

srikanthyadake




msg:4128654
 8:37 am on May 7, 2010 (gmt 0)

<iframe id="fram" style="width:980px;height:400px;border:3px ridge;" src="image-rotator.html"></iframe>
Thanks it worked now.

But iframe not working in firefox and IE6 (as IE6 is still being used in most of computers here in INDIA).. any browser compatibility codes to be written?

srikanthyadake




msg:4130220
 4:28 pm on May 10, 2010 (gmt 0)

hello.. anybody to answer my iframe thing?

tedster




msg:4130381
 6:46 pm on May 10, 2010 (gmt 0)

More detail please - what does "not working" mean?

srikanthyadake




msg:4130771
 12:53 pm on May 11, 2010 (gmt 0)

i wanna display different pages in same window. so im using iframe. but when i use the iframe tag and target other pages to display in it (pages are opened when i click menu items just above iframe) it opens up in a new seperate window in firefox and IE. but this does not happen in chrome! it opens as i wanted, why not so in others? wat to do?

part of my code is below-

<li><a href="home.html" target="myframe">Home</a></li>
<iframe id="myframe" style="width:990px;height:430px;border:3px ridge;" src="randompics.html">
</iframe>

home page does not open up in frame in IE and firefox(seperate window). but opens in chorme.(same window)

rocknbil




msg:4130992
 6:47 pm on May 11, 2010 (gmt 0)

AH! One of the few cases outside a form where the name attribute is helpful. :-)

<iframe id="myframe" name="myframe" src="randompics.html">
</iframe>

srikanthyadake




msg:4131307
 11:45 am on May 12, 2010 (gmt 0)

cool.. it worked.. thanks.. :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved