+ Reply to Thread
Results 1 to 4 of 4

Thread: Help required with a screen resolution issue

  1. #1
    jvella is offline x10Hosting Member jvella is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    4

    Help required with a screen resolution issue

    Hi,

    I am in the process of creating a website, and as I am teaching myself PHP decided that it would be a good idea to try a few things like resizing the text, changing colour schemes, all of the usual accessibility stuff.

    I have a php file called menu.php, (code below) which holds the menu option and also the screen resize options.

    They both work, but I am looking for a way to not display the screen resize options if the page is viewed on a mobile device, ie. a PDA or mobile 'phone.

    It's the bits in red that I don't want to appear, and I am getting accessing the file using the include function, if that makes any difference.

    I would like it to be decided by the screen resolution, ie. if the screen is less than 800 pixels wide don't show the options, but I'm a bit stuck...

    Can anyone help please?

    Thanks in advance,

    John.

    Code:
     
    <ul id="Navigation">
    <li><a href="index.php">Home </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="about.php">About </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="news.php">News </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="photos.php">Photos </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="projects.php">Projects </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="weblinks.php">Web Links </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="forums.php">Forums </a></li> <img src="images/seperator.png" border=0> 
    <li class="last"><a href="index.php">Contact Me </a></li>
    
    <br />
    <hr />
    <a href="javascript:fsize(textsize,'px','content');" onclick="changetextsize(0);">[Reduce font size]</a>
    <img src="images/seperator.png" width="20px" border=0>
    <a href="javascript:fsize(textsize,'px','content');" onclick="changetextsize(1);">[Increase font size]</a>
    </ul>

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Help required with a screen resolution issue

    First thing, the only legal children of an unordered list (<ul>) are list elements (<li>). Second, browsers already include the ability to change font size and zoom in or out. That being said, there are still good arguments for including the functionality in a page, so here's one way.

    The browser doesn't send the screen size to the server, so anything that depends on screen size has to be done client side, which basically means JS. I recommend having the text resizing widget hidden by default and revealed by JS. Since the widget won't work if JS is disabled, it's better to keep it hidden. Of course, if the browser doesn't support CSS at all, the widget will show up.

    HTML Code:
    <style type="text/css">
    .hide { display: none; }
    </style>
    ...
    <div id="ZoomWidget" class="hide">...</div>
    <script type="text/javascript">
    if (screen.width > 800) {
        document.getElementById('ZoomWidget').style.display="block";
    }
    </script>
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    jvella is offline x10Hosting Member jvella is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    4

    Re: Help required with a screen resolution issue

    Hi Mission and thanks for your help

    It had occured to me, (before I read your post) that I'd kinda mucked up my menu.php file, and slightly jigged it thus:

    Code:
    <ul id="Navigation">
    <li><a href="index.php">Home </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="about.php">About </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="news.php">News </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="photos.php">Photos </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="projects.php">Projects </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="weblinks.php">Web Links </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="forums.php">Forums </a></li> <img src="images/seperator.png" border=0> 
    <li class="last"><a href="index.php">Contact Me </a></li>
    </ul>
    <a href="javascript:fsize(textsize,'px','content');" onclick="changetextsize(0);">[Reduce font size]</a>
    <img src="images/seperator.png" width="20px" border=0>
    <a href="javascript:fsize(textsize,'px','content');" onclick="changetextsize(1);">[Increase font size]</a>
    <hr />
    I am slightly confused by what you mean by the term widget. Are you referring to the javascript file called by the href in the bit I want to hide on PDAs, etc?

    Sorry if I sound a bit dense, but any more information you could provide would be gratefully received.

    Thanks again,

    John.

    PS. Slightly off topic, but there was a security question to answer before I posted this... "What colour is the sky?" I've just looked out of the window and it's definitely grey, but for some reason the computer thinks it's blue! Have I got an optimistic PC?!? ;)

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Help required with a screen resolution issue

    Quote Originally Posted by jvella View Post
    Hi Mission and thanks for your help

    It had occured to me, (before I read your post) that I'd kinda mucked up my menu.php file, and slightly jigged it thus:

    HTML Code:
    <ul id="Navigation">
    <li><a href="index.php">Home </a></li> <img src="images/seperator.png" border=0> 
    <li><a href="about.php">About </a></li> <img src="images/seperator.png" border=0> 
    ...
    Better, but you still have some <img> as children of the <ul>. (Note: I changed the tag from '[code]' to '[html]' to improve readability). You might want to use W3C's HTML validator.

    Quote Originally Posted by jvella View Post
    I am slightly confused by what you mean by the term widget. Are you referring to the javascript file called by the href in the bit I want to hide on PDAs, etc?
    A "widget" is a UI element that the user interacts with, also called a "control". Buttons, scrollbars, sliders, comboboxes, and radio buttons are all widgets. In this case, it's the text resizer. I'm using the term a little broadly, as a proper widget displays some information about its state so that (from the user's perspective) widget input & output aren't distinguishable. Also, a widget doesn't have a specific function (such as text resizing), it just defines a way of interacting with it, a particular method of control.

    Quote Originally Posted by jvella View Post
    PS. Slightly off topic, but there was a security question to answer before I posted this... "What colour is the sky?" I've just looked out of the window and it's definitely grey, but for some reason the computer thinks it's blue! Have I got an optimistic PC?!? ;)
    All computers are optimists, excepting Marvin and some web servers.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Replies: 4
    Last Post: 04-26-2009, 08:55 AM
  2. Screen resolution of visitors
    By wjh2303 in forum Programming Help
    Replies: 3
    Last Post: 03-24-2009, 10:53 PM
  3. changing proportions for screen resolution
    By bunglebrown in forum Graphics & Webdesign
    Replies: 2
    Last Post: 01-22-2009, 04:07 AM
  4. Check Screen Resolution With PHP
    By kbjradmin in forum Programming Help
    Replies: 11
    Last Post: 04-17-2008, 07:40 AM
  5. Your Screen Resolution/ Size
    By sandogg in forum Computers & Technology
    Replies: 42
    Last Post: 01-10-2008, 03:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers