screen.width variables embedded or parsed to php?

R

RelaxoRy

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?
 
M

Mick White

RelaxoRy said:
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
 
R

relaxory

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
 
M

Mick White

relaxory said:
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

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
 
R

Richard Cornford

Mick White wrote:
"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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top