1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Rep Power

    using javascript variables?

    Is it possible to use javascript variable values for screen.height and screen.width within PHP, so that for example, a font size can be set based on the width of the screen/window? I've tried this with no success, and now I wonder if it is even possible because the PHP code will be evaluated before the Javascript code is evaluated...
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Rep Power


    well, as u noticed u'r self, java script is a user side application while php is a server side application there for the php has to be evaluated and executed first and then send all necessery bits and data to the client (usually some html code and javascript) which will then be evaluated by the user's browser.
    one way to solve u'r problem is to take it in to 2 steps.
    first is to send some html (and Java Script) page to the user which will say something like "wellcome to my site" and will include a meta - refreash tag or java script order (or location directive) to refresh the page within X seconds (where X is something like lets say 5). this plain and rather simple page will do the refreshing with the results of the screen hight / width and what ever data u need to retrive from the client's browser. the data will be passed to the next page (the page in the refresh order/directive...) NextPage.html?width=AAA&hight=BBB (where AAA and BBB are the result of the javascript).
    now after the refresh, (which will be done by the clients browser, u will have u'r hight and width in the $_GET['width'] and $_GET['hight] in u'r php script.

    hope i was clear enough.
    Best of Luck
    You cant see yourself in the mirror with your eyes closed.

IMN logo majestic logo threadwatch logo seochat tools logo