SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Javascript value to PHP
-
Aug 27, 2003, 03:40 #1
- Join Date
- Jul 2001
- Location
- Slovenia, Europe
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Javascript value to PHP
Hello folks
Ok I need to pass my screen resolution value (that I get from JavaScript) to my php variable... of course without reposting )I hate redirects).
Let me explain better.
I am creating a 100% width portal.
Now my site looks just fine if viewed with resolution 1280x.....
Therefor I need to make some minor adjustments for minor resolutions.
Now I've managed to include CSS files like:Code:<script language="JavaScript1.2"> if (screen.width==1024){ document.write('<link href="hd/ci1024.css" rel="stylesheet">'); }else if (screen.width ==1280){ document.write('<link href="hd/ci1280.css" rel="stylesheet">'); } </script>
But now for some other adjustments I just need to make different layouts. That's why I need to include diferent php script.
My site is constructed this way:
index.phpPHP Code:<?
$pageTitle="Home";
include_once(getenv("DOCUMENT_ROOT")."/lib/config.inc.php");
$pagePic="";
$pageDescription="";
$pageKeywords="";
require_once($cnfg_head_file);
require(CNFG_HOME."/main.inc.php");
require_once($cnfg_footer_file);
?>
I need to pass this to php. so I could use:
PHP Code:require(CNFG_HOME."/main$RES.inc.php" );
Is this possible. I know for other pages is not difficult with use of cookies, sessions etc. But I need this for my first page (or better said - entry page).
I thought about to use flash. So I can pass myJS value to flash movie that will process it and write the value into the DB wich can be then easyly retrieved by PHP.
What do you think? are there any better ways to do the "magic" ??
Thank alot 4 your answersDamir Sečki
PHP (mainly cakePHP)/mySQL/JavaScript (jQuery)/HTML/CSS developer
BlabberStar.com - Tratsche.de - Petteguless.it
-
Aug 27, 2003, 13:07 #2
- Join Date
- Jul 2003
- Location
- Moncton, New Brunswick, Canada
- Posts
- 247
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Damir Secki
You would just echo out the js value like this:
PHP Code:function get_res()
{
$res = "/main";
$res .= "<script type=\"text/javascript\">document.write(screen.width);</script>";
$res .="inc.php";
return $res;
}
echo get_res();
// outputs '/main1024inc.php' or whatever res your on
// for you particular problem
require(CNFG_HOME.get_res());
-xDev
-
Aug 27, 2003, 13:14 #3
- Join Date
- Jul 2001
- Location
- Slovenia, Europe
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's working!
I cannot believe it.
Thank you very mutch!!!Damir Sečki
PHP (mainly cakePHP)/mySQL/JavaScript (jQuery)/HTML/CSS developer
BlabberStar.com - Tratsche.de - Petteguless.it
-
Aug 27, 2003, 13:33 #4
- Join Date
- Jul 2003
- Location
- Moncton, New Brunswick, Canada
- Posts
- 247
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Damir Secki
Cheers!
-
Aug 28, 2003, 07:20 #5
- Join Date
- Mar 2002
- Location
- Lappeenranta, Finland
- Posts
- 176
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
One thing thou, designing sites for different resolutions has a problem.
I happen to have a double monitor setup here, my resolution is 3200*1200. I do not surf fullscreen, ever, it would suck.
So maybe you should not check the screen width, maybe instead you should check the browser area width.
just a thought
-
Aug 28, 2003, 07:24 #6
- Join Date
- Jan 2002
- Location
- Canada
- Posts
- 6,364
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Or maybe you should just use percentages, as apposed to resolutions. I did a similar thing, with one of my sites, and it didn't work out. It was a pain to do, and certain resolutions still didn't work properly.
- Nathan
Bookmarks