By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

screen.width variables embedded or parsed to php?

P: n/a
I have 2 screen sizes I want to accomodate for. screen.width <= 800
and > 800. This is because If it's one or the other, I want a
different set of menu graphics, and to set variables for my javascript
menus to popup in the right position.

So do I write a function ...
....get the screen.width fine, and break off into a loop, setup some
variables. But then I want to use these in the HTML page similar to
as if I would ASP <%=tWidth%>. Can I do this with JavaScript? Off
memory not.. The pages are in PHP.. so can I some how get my
Javascript to parse its variables to php to embed into the document?
Perhaps I can do it in a session variable or make some cookies in
javascript?

I just want to avoid 2 sets of html documents, as I want the text to
remain in one place. And I want to avoid PHP writing big bodies of
<<<HTML;

ideas?
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
RelaxoRy wrote:
I have 2 screen sizes I want to accomodate for. screen.width <= 800
and > 800. This is because If it's one or the other, I want a
different set of menu graphics, and to set variables for my javascript
menus to popup in the right position.

So do I write a function ...
...get the screen.width fine, and break off into a loop, setup some
variables. But then I want to use these in the HTML page similar to
as if I would ASP <%=tWidth%>. Can I do this with JavaScript? Off
memory not.. The pages are in PHP.. so can I some how get my
Javascript to parse its variables to php to embed into the document?
Perhaps I can do it in a session variable or make some cookies in
javascript?

I just want to avoid 2 sets of html documents, as I want the text to
remain in one place. And I want to avoid PHP writing big bodies of
<<<HTML;

ideas?


You need to remember that a user's screen width is quite often not the
same width as his browser viewport.
Mick
Jul 23 '05 #2

P: n/a
yeah its ok, i took that into consideration. i overcompensated in my
graphic widths. I didnt classify them into specific resolutions, I just
made one big and one small, which roughly fall around the number 800 and
1024 for screen widths

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

P: n/a
relaxory wrote:
yeah its ok, i took that into consideration. i overcompensated in my
graphic widths. I didnt classify them into specific resolutions, I just
made one big and one small, which roughly fall around the number 800 and
1024 for screen widths

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Then I recommend that you create 2 stylesheets (CSS), one for 800+ and
one for everything else.
if(screen.width){
res= screenwidth>799? "hi":"lo";
}

document.write('<link rel="stylesheet" href=\"'+res+'\"
..csstype="text/css" />')

Then you could create 2 external stylesheets:

"hi.css" and "lo.css"
<noscript><link rel="stylesheet" href="lo.css" type="text/css" /></noscript>
Mick
Jul 23 '05 #4

P: n/a
Mick White wrote:
<snip>
"hi.css" and "lo.css"
<noscript><link rel="stylesheet" href="lo.css" type="text/css"
/></noscript>


Valid HTML 4 (or XHTML) will not allow this as NOSCRIPT is a - %block -
element and not allowed to appear in the HEAD element, and LINK is a -
%head.misc - element and only allowed to appear in the HEAD element.
Combining them in this way will make any resulting page subject to the
vagaries of browser error-correcting and might have many outcomes, some
of which would probably be undesirable.

Richard.
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.