I have 2 separate questions. They are related so I hope it works to take care of both of them in one thread.
I have this code that works fine for what it does:
<head>
<script type="text/javascript">
function alertSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
new_win = window.open('index.php?width=' + myWidth+'&height='+myHeight)}
</script>
</head>
<body>
<a href="javascript:alertSize();">Go to Album</a>
</body>
but I want to be automatically redirected without having to click the link "Go to album". Also I want the new page to open in the same tab, not a new one. I mostly copied and pasted the code from different sites so I'm not sure what all the code means. Is it the "new_win" that is telling it to open in a new window or tab and if so, what coding should be used to open in the same tab. Also, as I said I don't want to have to click anything.
Then:
On another page I want to somehow incorporate this script and combine the href variables with a variable submitted through php. Here is the code of the php file:
<head><link rel="stylesheet" href="../../../style.css" /></head>
<?php
// open this directory
$myDirectory = opendir("./thumb");
// get each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// close directory
closedir($myDirectory);
// count elements in array
$indexCount = count($dirArray);
//Print ("$indexCount files<br>\n");
// sort 'em
sort($dirArray);
// print 'em
// loop through the array of thumnails and display them in table form
$width=$_REQUEST['width']*.8;
echo '<table align="center" width="80%">';
$index=2;
while($index < $indexCount) {
echo '<tr>';
$numcolumns=intval($width/120);
for($columns=$columns; $columns<$numcolumns; $columns++){
$cellwidth=intval(100/$numcolumns);
if($index>$indexCount-1){break;}
echo '<td width="'.$cellwidth.'%" align="center"><a href="view2.php?id='.$index.'"&height='.myHeight.'&width='.myWidth><img src="./thumb/'.$dirArray[$index].'" width="90%" alt="Smile"></td>';
$index++;
}
echo '</tr>';
$columns=0;
}
echo '</table>';
?>
In the red href code I want to also ad the myWidth and myHeight variables from the above javascript code (the green code is similar to what I want but I don't know that it is written correctly since they are javascript variables I am wanting but hopefully you get the idea of what I want). Since this is a different php file I will also need to add the javascript code in an echo statement but will probably need to modified somewhat since I will just be needing the variables from it and not open a new page. I hope you understand what I mean.
So could I get some help with the redirecting issue and also how I would need to change my javascript code and combine it with my php code in order to get the desired results.