iframe question

Associate
Joined
18 Aug 2004
Posts
1,886
Location
midlands
hi,

is it possible to have an iframe hidden, then when you click a link it opens up?

so that it is only viewed when the user wants to see it?

or maybe theres a better way to do it?... also is it possible to have it so it sort of slides down when wanted to be viewed...

hope someone can help
nickels
 
Could be done with javascript :) You could just put the iframe in a div and set it to display: none and then do an onClick function on a button which sets it to display: block :)
 
dont know how to do it :(

looking for something like the things on the side of last.fm but with a webpage in them

could someone make the code? would be very happy if it was possible

thanks
nickels
 
yes you can. You have 2 options:


1. You can set the visibility style property of the iFrame to "hidden". This will still allocate the space for the frame, but won't show it

2. You can set the "display" stype property of the iFrame to "none". This will not allocate the space and won't show it.

in your JScript you can then alter this style property so the iFrame will be shown later on.
 
nickels said:
just tried it and the iframe messes up the layout??? could it be the css or something :confused:

you'll need to play around with the "visibility:" and "display:" style settings a bit, as well as placing your iFrame into a DIV.
 
addy_010 said:
i have a class in css file that has a display:none setting, then on the webpage, i have the js change it from none to block and then vice versa. that works fine for me

can i have the code? i dont know how to do js
 
right i sorted it out, but when i put text in the div to be hidden it works but when i put an iframe in it, it messes up the layout :/

Code:
<script>
function toggleDiv(div)
{
if(div.style.display == "none")
div.style.display = "block";
else
div.style.display = "none";
}
</script>

 <div id="benefits"><table cellpadding="3" cellspacing="0" width="300">
<tr>
<td style="cursor:hand;" onclick="toggleDiv(document.all.testdiv);"> Click here to view/hide comments
<font face="arial">&nbsp;</font></td>
</tr>
<tr>
<td>
<div id="testdiv" name="testdiv" style="display:block;"><iframe src="http://www.google.co.uk"></div>
</td>
</tr>
</table></div>
 
Back
Top Bottom