Log in

View Full Version : open in iframe



pkcidstudio
06-30-2006, 12:22 AM
hey all. i have a javascript and php script and i have just been at it way to long today that my brain is starting to fart.
any who i want my javascript to open up in a iframe i have made instead of in the blank window it was built to open up in.
here is the script. (clients)


<tr>
<td width="400" height="384" align="center" valign="middle"><iframe name="gallery" scrolling="no" align="middle" height="350" width="350"></iframe></td>
<td width="350" align="center" valign="middle"> <script type="text/javascript">
<!--this function needs to be change to display in iframe if image clicked-->
function view(url)
{
window.open(url, 'pic', '');
return false;
}

</script>

<table cellpadding="2" class="gallery">
<tr>
<?php

$path = 'styles/images';
$path_thumbs = 'styles/thumbs';
$extensions = array('jpg', 'jpeg', 'bmp', 'gif', 'png');

################################################## #############


$dir = opendir($path_thumbs);
$images = array();
$used = array();


while (($file = readdir($dir)) !== false)
{
$ext = strtolower(substr(strrchr($file, '.'), 1));

if (in_array($ext, $extensions))
{
$images[] = $file;
}
}

function get_rand()
{
global $used, $images;

$rand = rand(0, sizeof($images) - 1);

if (in_array($rand, $used))
{
$rand = get_rand();
}

return $rand;
}

for ($i = 1; $i <= 9; $i++)
{
$rnd = get_rand();
$used[] = $rnd;

echo '<td><a href="'. $path .'/'. $images[$rnd] .'" onclick="return view(this.href);">
//this part needs to be changed to onclick="something"
<img src="'. $path_thumbs .'/'. $images[$rnd] .'" align="middle" border="0" />
</a></td>' ."\n";

if ($i == 3 OR $i == 6)
{
echo '</td><tr>';
}
}

?>
</tr>
</table></td>
</tr>

thank for the help in advance

Twey
06-30-2006, 12:27 AM
function view(url)
{
window.open(url, 'pic', '');
window.frames['framename'].location.href = url;
return false;
} Remove the bit in red, add the bit in blue, and change the bit in green to the name of your frame. And if you're colourblind, gods help you. :)

pkcidstudio
06-30-2006, 12:31 AM
thanks tway,
stud qualitys on that now i can pack up for the day much help. much help.
http://www.ejlcustomgolf.com/virtualTour.php
if you had interest
any thoughts on how i can better do things would be great

Twey
06-30-2006, 12:41 AM
Specify a white background-color, and validate it (validator.w3.org/check?uri=http%3a%2f%2fwww%2eejlcustomgolf%2ecom%2fvirtualTour%2ephp)!