Email conversation
From | Nancy Stefanik |
To | Me |
Subject | Problems with loading external pics into an IFrame |
Date | 25 April 2005 19:18 |
Hello,
While I searched your site to find the solution to my problem, I haven't
found any, which prompted me to email you with the issue at hand:
Brief: I have an employee directory that is loaded into a table
(dynamically). I also have a picture stored in a folder (same root) that
with FSO will "push" a camera icon to link to that employee's picture, if
there is a picture. So far, so good.
On the page with the dynamic table I also have a Floating <Iframe> with
images of all employees scrolling side to side (Slide show effect)
When the end-user clicks on the camera icon (in the dynamic table) that
employees pic should replace the slideshow but instead the picture relaces
the whole page instead of loading into the IFRAME. ?!
Here's the chunk of code that calls the Floating IFrame:
var iframetag='<iframe id="masterdiv" name="masterdiv" src="../people.htm"'
+' width="101px" height="150px" marginwidth="0" marginheight="0" hspace="0"'
+' vspace="0" frameborder="1" scrolling="no" style="position: absolute; '
+'left: -500px; top: -500px; border:8px solid #336699;"></iframe>'
Here's the code calling the camera icon (if there is a corresponding
picture in the image folder)
<%
If (fso.FileExists(strpath)) Then%>
<a href="<%=PICurl%>" OnClick="javascript:changePic()" class="docs">
<img src="../img/EMPpic.jpg" border="0"></a>
<%
Else
response.write("<P class=""dir"">n/a</P>")
End If
%>
And here's my changePic function:
<script>
function changePic(){
window.frames['masterdiv'].window.location.replace()
}
</script>
Please help??
Thank you,
nancy
From | Me |
To | Nancy Stefanik |
Subject | Re: Problems with loading external pics into an IFrame |
Date | 25 April 2005 22:38 |
Nancy,
> When the end-user clicks on the camera icon (in the dynamic table) that
> employees pic should replace the slideshow but instead the picture
> relaces the whole page instead of loading into the IFRAME. ?!
> <script>
> function changePic(){
> window.frames['masterdiv'].window.location.replace()
> }
> </script>
From the looks of this, your slideshow script is interfering with the
window references for the iframe - this may well be because of the way it
generates the content of the iframe.
Anyway, since it looks like you are stuck with a broken reference, you can
use some other techniques:
1. use normal links instead to target the iframe - the most accessible, but
it will add an extra history entry:
<a href="picture.jpg" target="masterdiv">
2. use DOM to reference the iframe and set the SRC - it will add an extra
history entry and Safari might load the page twice (bug):
document.getElementById('masterdiv').src = 'picture.jpg';
3. access the location object directly on the iframe - this may suffer from
the same bug as you already have:
window.frames['masterdiv'].location.replace('picture.jpg')
4. use DOM to recreate the iframe with the new item, and use replaceChild
to replace the existing one. Not very convenient.
You should find that at least one of these will do what you need.
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Nancy Stefanik |
To | Me |
Subject | Re: Problems with loading external pics into an IFrame |
Date | 26 April 2005 22:12 |
Thanks Marc,
You know... sometimes the simplest solutions are the hardest to find !!
your first suggestion worked like a charm,
Thanks again!