Cherubae
03-12-2003, 03:41 PM
//start newbie javascript question
I'm trying to change my page layout depending on a user's screen resolution via javascript. If a user is 1024x768, I want a script that scrolls aross the top of the page to apear. If they don't meet the requirements, I don't want the script to appear.
I figured I could use the screen.width to help me determine what the user's screen size was and then display the file imported via php. Unfortunatly it's not working and I receive a "parse error, unexpected T_CONSTANT_ENCAPSED_STRING " message. I've got different style sheets being used depending on resolution but I can't get this script to work:
<script type="text/javascript">
<!--
if ((screen.width >= 1024)){
document.write('<div id="top">');
document.write('<?php');
document.write('include \'cloud_scroll.php\';');
document.write('?>');
document.write('</div>');
}
-->
</script>
If I add an escape character before the "?" ('<\?php') ) ,that gets rid of the parse error but the php portion of it doesn't work and the cloud_scroll.php file isn't included.
Is the problem with the way I'm using document.write?
// end newbie quesiton
- C
I'm trying to change my page layout depending on a user's screen resolution via javascript. If a user is 1024x768, I want a script that scrolls aross the top of the page to apear. If they don't meet the requirements, I don't want the script to appear.
I figured I could use the screen.width to help me determine what the user's screen size was and then display the file imported via php. Unfortunatly it's not working and I receive a "parse error, unexpected T_CONSTANT_ENCAPSED_STRING " message. I've got different style sheets being used depending on resolution but I can't get this script to work:
<script type="text/javascript">
<!--
if ((screen.width >= 1024)){
document.write('<div id="top">');
document.write('<?php');
document.write('include \'cloud_scroll.php\';');
document.write('?>');
document.write('</div>');
}
-->
</script>
If I add an escape character before the "?" ('<\?php') ) ,that gets rid of the parse error but the php portion of it doesn't work and the cloud_scroll.php file isn't included.
Is the problem with the way I'm using document.write?
// end newbie quesiton
- C