Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

resolution sniff + php include file

Status
Not open for further replies.

boyfromoz

Technical User
Feb 1, 2001
469
AU
I'm trying to do a resolution sniff, the result will determine which file loads as my header. Can't get it to work. Can someon have a quick peek at my code and tell me where I'm goign wrong?

<script language=&quot;javascript&quot;>
//header
if (window.screen){
var w = screen.width;

if(w<740){
document.write(&quot;<?php require_once('test2.php'); ?>&quot;);
}
if(w>=740 & w<835)
document.write(&quot;<?php require_once('test2.php'); ?>&quot;);

if(w>=835){
document.write(&quot;<?php require_once('test2.php'); ?>&quot;);
}
}
//finishheader
</script>


Ta
 
Well, javascript is clientside code, and you're trying to doc.write PHP code (server-side code).

Try something like this instead:
Code:
<?
 if(!isset($_GET['w']))
 {
  echo '<script language=&quot;javascript&quot;>';
  echo 'location.replace(&quot;'.$PHP_SELF.'?w=&quot;+screen.width);';
  echo '</script>';
 }
 else
 {
  if($_GET['w']<740){require('test2.php');}
  else if($_GET['w']>=835){require('test2.php');}
  else {require('test2.php');}
 }
?>

That code shouldn't be used on its own, it is just meant to give you an idea. -gerrygerry

&quot;I'm doin' a one-nighter for bitin' Ed the mail man... the guy was tryin' to cast a spell on me... like a wizard or something.&quot;
&quot;Are you sure about that?&quot;
&quot;I dunno... maybe he was just wavin'...&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top