homepage Welcome to WebmasterWorld Guest from 54.242.200.172
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

    
Resize picture to fit in iframe
iframe resizing for pictures
Ricey2005




msg:601106
 9:39 am on Jul 27, 2005 (gmt 0)

Hi
I have a page and I want to have an iframe centered at the top and below it alot of little images, when I click on the image i want the image to resize to fit the iframe (obviously the image being bigger than the iframe)
Can anyone help
I dont know anything about php or the likes thank you

 

travelin cat




msg:601107
 6:13 pm on Jul 27, 2005 (gmt 0)

Assuming the larger graphic is 200x500, on the page with your iframe put this:

<iframe src="test.html" height="200" width="500"></iframe>

on test.html put this:

<a href="2.gif"><img src="1.gif" border="0"></a>

where 1.gif is the smaller graphic and 2.gif is the 200x500 graphic

When the viewer clicks on 1.gif, 2.gif will pop up filling the iframe beccause the iframe and it are the exact same size....

hope this helps.

Herenvardo




msg:601108
 2:17 pm on Jul 28, 2005 (gmt 0)

A very efficient way to get the results you're asking for, is to use a bit of server-side scripting. I'll put here a sample in ASP, but this is also doable on php and almost any server-side scripting technology.
Replace the $x, $y, $filename and things like those with the params you need.
The host file (the file where the iframe is):
...
<iframe name="the_frame" height="$y" width="$x"></iframe>
<a href="show_img.asp?fname=$file1.jpg" target="the_frame">
<img src="$file1.jpg" height="$y1" width="$x1" alt="click to enlarge" /> </a>
...
<iframe name="the_frame" height="$y" width="$x"></iframe>
<a href="show_img.asp?fname=$fileN.jpg" target="the_frame">
<img src="$fileN.jpg" height="$yN" width="$xN" alt="click to enlarge" /> </a>

The framed file "show_img.asp":
<%
Dim strFile, strResponse
strFile = Request("fname")
strResponse = "<html><head></head><body>" & vbCrLf
strResponse = strResponse & "<img src=" & Chr(34) & strFile & Chr(34) & _
" height=" & Chr(34) & "$y" & Chr(34) & " width=" & Chr(34) & _
"$x" & Chr(34) & "/>"
strResponse = strResponse & "</body></html>"
%>

The only difficult part is to keep html params "quoted" without these quotes being parsed by the ASP as opening/closing of strings. The call Chr(34) returns a 1-length string with the 34th character in ASCII, which is '"'. Beyond the weird thing of the quotes, I think there is no difficulty on implementing that; even so, if you have any doubt or question, I'll be glad to help you either via reply (generic questions) or sticky mail (if specifics are needed).

Hoping be useful,
Herenvardö

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