473,668 Members | 2,519 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

screen.width variables embedded or parsed to php?

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
4 1964
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
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
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><li nk rel="stylesheet " href="lo.css" type="text/css" /></noscript>
Mick
Jul 23 '05 #4
Mick White wrote:
<snip>
"hi.css" and "lo.css"
<noscript><li nk 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3399
by: Dariusz | last post by:
I have a problem with a call a Javascript "window.open()" function which is executed as part of a PHP file when a user clicks on an thumbnail image. The PHP is executed which passes some variables to Javascript to execute the new window opening. But as it does this, the main window is loaded which is blank (the browser URL bar shows the URL of the URL passed to the PHP / Javascript script). I would like to keep the gallery page visible...
18
11641
by: DavidS | last post by:
Have resW=screen.width; resH=screen.height in javascript. How can I read these values in ASP.NET source code - Page_Load function of code behind? Any suggestions?
10
4475
by: ManwSloHand | last post by:
ARGH! I have a c#.net web application. I need to retrieve screen height and width into a variable. I know this is incredibly stupid but HOW THE HECK DO I DO IT??!?!?! A copy to rick1ryan@gmail.com would be much appreciate also. Thanks in advance.
5
2595
by: Pat | last post by:
I am trying to place a dialog in the center of the screen based on a users screen resolution. I can get the width and height of the screen, but I can't seem to use the following: root.geometry('WxH+X+Y') It appears the values for X and Y need to be integers and not a variable like width/2-40 S
14
48973
by: Seige | last post by:
Ever had headache when you can't resize the background width using CSS: body{ background: url(/images/bg.jpg) ; background-width: 800px; } It won't work, would it? Of course not, it's not even defined in CSS. So, let's try to work it out using Javascript: There are two methods, first method you prepare plenty of different
11
3183
by: srini | last post by:
Frens, I am trying to get screen resolution of the client machine using javascript and use those values in my project. I looked at some of the examples given in this group, i tried to implement the same but everytime i get nulls, i tested javascript by keeping alert statements and everything looks good to me.... I am trying to figure it out what peice of info is missing in this code..... Here is my code
9
4744
by: Ray | last post by:
Hello, We have a requirement that when a user click a button to signify he wants to edit a certain area, everything else on the browser screen but that area will be disabled. In effect, it's analogous to a modal dialog box, the difference being the "dialog box" in this case is within the screen itself, not a separate popup one like a modal dialog box. It's just a certain area of the screen that becomes enabled when the user clicks the...
6
2162
by: Chris Carlen | last post by:
Hi: I have an embedded system, platform: TI TMS320F2812 32-bit integer DSP. A module (.c file) contains external (to the funcs in that module) variables which are used to affect the operation of the program (other modules). These variables are only read by other parts of the program, but are to be set by a user interface which consists of an RS-232 terminal command line interface. The command parser for this interface responds to...
3
6779
by: Safalra (Stephen Morley) | last post by:
(Note: I'm not trying to do anything stupid based on the user's screen size - I'm just curious.) At work today I was looking at the visitor statistics for a client website, and noticed that the recorded screen resolutions included results that clearly referred to dual display systems - 2560 by 1024, for example. The statistics package is obtaining this data from window.screen.width. I wasn't aware of this behaviour of...
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8889
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.