dcass
asked on
div/iframe parent child float
I have an HTML where I need the iframe to be positioned just below the onmouseover on each line (from the database).
I understand that I probably need a parent and child div, but don't know enough to get it right.
Thanks for your help.
I understand that I probably need a parent and child div, but don't know enough to get it right.
Thanks for your help.
<script>
function show(temp)
{
document.getElementById(temp).style.display="inline";
}
function hide(temp)
{
document.getElementById(temp).style.display="none";
}
</script>
</head>
<div id="billboard_content" style="text-align:center;">
<table cellpadding="0" cellspacing="0" class="tablesorter" id="myTable">
<tr>
<th style="text-align: center;" nowrap><img src=Images/desc.gif>Bid Date<img src=Images/asc.gif></th>
<th nowrap><img src=Images/desc.gif>Project Description<img src=Images/asc.gif></th>
</tr>
<!-- this next section will be in a loop and load from the database. ctr=#records -->
for ($i=0;$i > $ctr;i++) {
<tr>
<td style="text-align: center">$Date$i</td>
<td>
<B><a onmouseover="show('temp'$i)" onmouseout="hide('temp'$i)">$Desc$i</a></b>
</td>
</tr>
}
</table>
<!-- where does the parent go? Can the child stay here? -->
<div style="width: 200px; position: relative; float: bottom;">
<div id='temp' style="position: absolute; z-index:0" >
<iframe width="200" height="415" src="temp.html" scrolling="auto"></iframe>
</div>
</div>
</div>
Here is a "easier-to-use" example. You don't need javascript, but if you can ensure your document is declared as xHTML, ie document starts with these lines:
Please note that this is a full weg page, so you can save it as .html and preview/test.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
...
than you could use this simple example (it's your original code altered in a way to work like you desire):<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Example page</title>
</head>
<body>
<style type="text/css">
div.iframe-holder > div {
position: absolute;
top: -999em;
left: -999em;
width: 200px;
height: 415px;
z-index: 1000;
/* Adjust these two to control
distance from the element you
mouseover and the iframe: */
margin-top: 10px;
margin-left: 50px;
}
div.iframe-holder > div > iframe {
width: 100%;
height: 100%;
}
div.iframe-holder:hover > div {
top: auto;
left: auto;
}
</style>
<div id="billboard_content" style="text-align:center;">
<table cellpadding="0" cellspacing="0" class="tablesorter" id="myTable">
<tr>
<th style="text-align: center;" nowrap><img src="Images/desc.gif" alt="" />Bid Date<img src="Images/asc.gif" alt="" /></th>
<th nowrap="nowrap"><img src="Images/desc.gif" alt="" />Project Description<img src="Images/asc.gif" alt="" /></th>
</tr>
<!-- this next section will be in a loop and load from the database. ctr=#records -->
for ($i=0;$i > $ctr;i++) {
<tr>
<td style="text-align: center">$Date$i</td>
<td>
<div class="iframe-holder">
<B><a href="temp.html" onclick="return false">$Desc$i</a></b>
<div><iframe src="temp.html"></iframe></div>
</div>
</td>
</tr>
}
</table>
</div>
</body></html>
Please note that this is a full weg page, so you can save it as .html and preview/test.
ASKER
Thanks for both - I needed both for comparison.
Imantas - we prefer yours but we need the javascript functionality because we'll be passing variables, so if you have a sec and can throw that back in, we'd really appreciate it.
Imantas - we prefer yours but we need the javascript functionality because we'll be passing variables, so if you have a sec and can throw that back in, we'd really appreciate it.
@imantas
Saying "easier-to-use" is misleading and customers will wrongly interpret that.
@dcass
If my code is not exactly what you expect, then say something. I will be happy to adjust it for you.
Is there a specific reason why you feel an iframe should be used?
Saying "easier-to-use" is misleading and customers will wrongly interpret that.
@dcass
If my code is not exactly what you expect, then say something. I will be happy to adjust it for you.
Is there a specific reason why you feel an iframe should be used?
ASKER
Boss says "no ajax" - wants iframe with javascript.
He decided to change the criteria, though, to absolute positioning instead of auto or relative.
If I have trouble with this, I'll let you know.
We both prefer the behavior of hover but have to have mouseover (or some event) to call javascript with variables.
Can you use both?
He decided to change the criteria, though, to absolute positioning instead of auto or relative.
If I have trouble with this, I'll let you know.
We both prefer the behavior of hover but have to have mouseover (or some event) to call javascript with variables.
Can you use both?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both were very helpful
View it here:
http://pocourl.com/example1/
Download the code that is attached:
example1.zip
index.html
Open in new window
fetchContent.php
Open in new window
example1.zip