Page 1 of 1
Auto Resizing
Posted: Sat Jul 31, 2004 3:29 pm
by John Cartwright
Hmmm I've been googling for awhile and couldn't figure out a way to auto resize a popup to fit to a picture.
This is what I got so far
Code: Select all
function popup()
{
window.open('large_pics/clantemp1.jpg','','width=1,height=1,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=no,top=0,left=0');
}
//-->
</SCRIPT>
Note I set the width and height to 1 because I read somewhere that it will obviously resize to the picture but it doesntt.
Any help much appreciated TY
Posted: Sat Jul 31, 2004 4:49 pm
by feyd
untested..
Code: Select all
<html>
<head><script language="Javascript 1.2"><!--
function autoResize(id)
{
var obj = document.getElementById ? document.getElementById( id ) : document.allї id ];
if( obj && self.resizeTo )
{
self.resizeTo(obj.width + 10, obj.height + 10);
}
}
//--></script></head>
<body onload="autoResize('imageID')"><img id="imageID" src="someimage.jpg" /></body>
</html>
Posted: Sat Jul 31, 2004 4:55 pm
by John Cartwright
I'm a bit confused by this: what is ID refering to?
Posted: Sat Jul 31, 2004 4:58 pm
by John Cartwright
if this script works the way I think it is it woulnd't work...
because the image is always changing depending on which picture is clicked.
Posted: Sat Jul 31, 2004 5:35 pm
by feyd
the calling script can either call a php script that writes this code, or can directly write the code to the window.
Posted: Sat Jul 31, 2004 9:02 pm
by John Cartwright
okay sorry feyd i was looking at the script all wrong but it still isn't working..... also I want it so you cannot see the scrollbar, toolbars etc etc ... i only know how to do that with window open

Posted: Sat Jul 31, 2004 11:35 pm
by feyd
combine yours and mine like so:
untestedCode: Select all
function popup(file)
{
window.open('popup.php?file='+file,'','width=1,height=1,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=no,top=0,left=0');
}
popup.php:
Code: Select all
<?php
if(!isset($_GET['file']))
die('No peeking!');
$file = $_GET['file'];
$html = <<<STOP
<html>
<head><script language="Javascript 1.2"><!--
function autoResize(id)
{
var obj = document.getElementById ? document.getElementById( id ) : document.all[ id ];
if( obj && self.resizeTo )
{
self.resizeTo(obj.width + 10, obj.height + 10);
}
}
//--></script></head>
<body onload="autoResize('imageID')"><img id="imageID" src="{S_IMAGEFILE}" /></body>
</html>
STOP;
$output = str_replace('{S_IMAGEFILE}',$file,$html);
echo $output;
?>
Posted: Sat Jul 31, 2004 11:46 pm
by John Cartwright
wow ty alot man
but to be quite honest im useless with heredoc never gotten them to work
Parse error: parse error, unexpected T_SL in C:\apachefriends\xampp\htdocs\j6\templates\main\popup.php on line 8
on popup.php
Posted: Sun Aug 01, 2004 12:24 am
by feyd
odd, it runs for me..
Posted: Sun Aug 01, 2004 9:54 pm
by John Cartwright
K this is my problem now...
I have to pass multiple vars in the header for the popup, so I use this link. Excuse the slopiness it's just so many quotes made it really dificult to put this all in 1 echo statement. So I break in and out of PHP.. atleast for now. But the problem is I'm getting OBJECT EXPECTED erorr when clicking on the link
Code: Select all
<a href='javascript: popup("large_pics/clantemp<?=$row['id'].$x."_".$_SESSION["{$row['id']}c"]?>.jpg");'><img src='small_pics/clantemp<?=$row['id'].$x."_".$_SESSION["{$row['id']}c"]?>.jpg' width='120' height='110' border='0' target='_blank'></a>
which will produce javascript: popup("large_pics/clantemp71_1.jpg");
and the function is
Code: Select all
<SCRIPT TYPE="text/javascript" LANGUAGE="javascript">
<!--
function popup(pic)
{
window.open('popup.php?pic='+pic+,'','width=1,height=1,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=no,top=0,left=0');
}
//-->
</SCRIPT>
Any help is much appreciated
Posted: Mon Aug 02, 2004 2:08 am
by John Cartwright
hmm stupid me I had an extra + after pic
ty feyd;
edit: but now the page isnt resizing.... sorry I;m so clueless in this area but what can ya do!
