Jump to content

load php page according to screen size


microbert

Recommended Posts

Hi,

 

I am trying to make a page where the footer is loaded according to the screen size, so if someone is accessing the website via a tablet will be a footer, if it is from the computer, there will be another footer.

 

my problem is that although it is recognizing the windows width, it is not changing the footer accordingly.

 

this is my code:

$width = "<script>document.write(window.innerWidth);</script>";
if ($width < 900)
{
include("footer_mobile.php");
}
else
{
include("footer.php");
}

for some reason it is always loading the else footer even though the windows with changes.

I added echo"$width" ; and the result of the variable was fine.

 

 

does anyone know what the problem is cause it is driving me crazy?

 

Link to comment
Share on other sites

How are you testing to see if the media query(ies) work? Are you adjusting a browser window...or are you testing on a mobile device? If you're testing on a mobile device and it's an iPhone, you'll need to add a <meta> tag to get things working. Perhaps the following article will help:

http://www.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/

 

If you scroll down a bit, there is a section for "Testing in an iPhone" which talks about the <meta> tag.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.