473,770 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing a Java variable to local PHP script.

Hello everyone,

I've spent quite some time now, looking for some information on how to
get this done, sadly none has helped me much, though.
I have a bit of java scrpt on a webpage (.php) to aquire the screen
resolution of the visiting user. Now I need to pass the java variable
to another variable on the same document.

I have a feeling, this will not be easy - as java is client- and php
server-sided. Now, if my assumption is corect, then it will be
neccessary to generate the page via .php on the webserver and send it
to the browser. Once loaded, java will be executed to aquire the used
screen resolution. These values (height/width) will have to be
returned to the server, prob. via post. The server will now have to
acknowledge the presence of these values and regenerate the webpage
once more, this time using the provided values.

I hope I've got it so far. Problem is - I don't have a clue about java
and only basics in php. Please help me get this accomplished, abd
don't forget: I'm not java savy.

kind regards,

Andy R.
Jul 17 '05 #1
4 3482
Andy R. wrote:
Hello everyone,

I've spent quite some time now, looking for some information on how to
get this done, sadly none has helped me much, though.
I have a bit of java scrpt on a webpage (.php) to aquire the screen
resolution of the visiting user. Now I need to pass the java variable
to another variable on the same document.


Firstly JavaScript != Java, they just share a name.

What you need to do is send a 'detect' page if you don't already know
the screensize. This will redirect to the original page passing the
screen size.

Create a file called screensize.php.
<?php
if ($_GET['screensize']) {
$_SESSION['screensize'] = $_GET['screensize'];
}

if (!$_SESSION['screensize']) { ?>
<html>
<head>
<script language=javasc ript>
window.location .href="<?=$PHP_ SELF?>?screensi ze=" +
screen.width + "x" + screen.height;
</script>
</head>
<body>
Checking screen size
</body>
</html>
<?php exit();
} ?>

Then just include('screen size.php'); at the top of your pages. All of
them will have $_SESSION['screensize'] set for you.

NOTE: the user may not have their browser full screen.
Jul 17 '05 #2
"Andy R." <No*******@mail inator.com> wrote in message
news:93******** *************** ***@posting.goo gle.com...
Hello everyone,

I've spent quite some time now, looking for some information on how to
get this done, sadly none has helped me much, though.
I have a bit of java scrpt on a webpage (.php) to aquire the screen
resolution of the visiting user. Now I need to pass the java variable
to another variable on the same document.

I have a feeling, this will not be easy - as java is client- and php
server-sided. Now, if my assumption is corect, then it will be
neccessary to generate the page via .php on the webserver and send it
to the browser. Once loaded, java will be executed to aquire the used
screen resolution. These values (height/width) will have to be
returned to the server, prob. via post. The server will now have to
acknowledge the presence of these values and regenerate the webpage
once more, this time using the provided values.

I hope I've got it so far. Problem is - I don't have a clue about java
and only basics in php. Please help me get this accomplished, abd
don't forget: I'm not java savy.

kind regards,

Andy R.


Don't reload the page, load a blank image,

<IMG SRC="blank.gif" NAME="imgscreen size">

<SCRIPT>
// do you stuff here
imgtime.src = "screensize.php ?w=" + varWidth + "&h=" + varHeight;
</SCRIPT>
then have screensize.php do something like this
<?php

// log your stuff here

header("Content-type: image/gif");
readfile("blank .gif");
?>
--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #3

Uzytkownik "Kevin Thorpe" <ke***@pricetra k.com> napisal w wiadomosci
news:40******** *************** @news.easynet.c o.uk...
Create a file called screensize.php.
<?php
if ($_GET['screensize']) {
$_SESSION['screensize'] = $_GET['screensize'];
}

if (!$_SESSION['screensize']) { ?>
<html>
<head>
<script language=javasc ript>
window.location .href="<?=$PHP_ SELF?>?screensi ze=" +
screen.width + "x" + screen.height;
</script>
</head>
<body>
Checking screen size
</body>
</html>
<?php exit();
} ?>


Consider using window.location .replace(url) instead, so that the back button
behaves more reasonably.

Jul 17 '05 #4
Hi Andy,

Assuming you only need to adjust the size of some html elements to the
screen size, you could do resizing entirely in javascript by something like:

<HTML><HEAD></HEAD>
<BODY onResize="scale Content()>
<script>
function scaleContent() {

getElement('ite mTableDiv').sty le.height=(wind ow.document.bod y.clientHeight)-179;
getElement('ite mTableDiv').sty le.width=(windo w.document.body .clientWidth)-130;
}

function getElement( elementId)
{
var element;

if (document.all) {
element = document.all[elementId];
}
else if (document.getEl ementById) {
element = document.getEle mentById(elemen tId);
}
else element = -1;

return element;
}
</script>

<div id=itemTableDiv style='height: 300px; width: 600px; overflow:
auto;' valign='top'>
<?php printItemTableP art() ?>
</div>
<script> scaleContent(); </script>
</BODY>
</HTML>

This resizes a DIV according to screen size minus (130, 179). You can
fill in different values to make it larger or smaller, or print the
proper values from php. It works in recent versions of both IE and
Mozilla, (not in Nescape 4.x). Of course you need to write the
printItemTableP art() function in php to produce the content of the div,
or just print it some other way from php.

This javascript will probably work on other types of html elements too,
as long as you give each one a different id, and as long as the scaling
is not making them too small for their own elements to fit in. Be aware
that the second script must be AFTER the definition of the elements that
are resized and after the functions that are called.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org
Andy R. wrote:
Hello everyone,

I've spent quite some time now, looking for some information on how to
get this done, sadly none has helped me much, though.
I have a bit of java scrpt on a webpage (.php) to aquire the screen
resolution of the visiting user. Now I need to pass the java variable
to another variable on the same document.

I have a feeling, this will not be easy - as java is client- and php
server-sided. Now, if my assumption is corect, then it will be
neccessary to generate the page via .php on the webserver and send it
to the browser. Once loaded, java will be executed to aquire the used
screen resolution. These values (height/width) will have to be
returned to the server, prob. via post. The server will now have to
acknowledge the presence of these values and regenerate the webpage
once more, this time using the provided values.

I hope I've got it so far. Problem is - I don't have a clue about java
and only basics in php. Please help me get this accomplished, abd
don't forget: I'm not java savy.

kind regards,

Andy R.


Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4345
by: Raju V.K | last post by:
can I use javascript and PHP in the following manner to create a pop-up window: <--- in <head> </head> <script language=javascript> function popup(folder1, file1) { window1=open("solution.php?folder=folder1&file=file1"); }
6
18975
by: Johan Louwers | last post by:
I have a qustion. I have to set a JAVA_HOME variable on a Solaris9 system... what kind of a variable? A system-defined.../....a user defined.../.....???? and how do I set this so java can work with it? I need this to be used by Tomcat at a webserver..... Thanks already,
3
14950
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
15
2251
by: Frances | last post by:
<html> <head> <script> function doIt() { var list = document.forms.product; var selItem = list.options.value; ^^^^^^^ </head>
5
3544
by: Paul | last post by:
Just wondering if someone could provide an example of passing a variable from the code behind to javascript in vb. I want to have one control have focus with the page loading with one condition and have another control with focus after the page loads from a different condition. A gets set in the code aspx.vb file and the script might look something like, <script language="javascript"> function DoHighlight(a) { if a = 1 {...
6
5581
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an object collection and stanrd using it it starts to fall apart. Clearly there is something about javascript's usage of passing "By ref" that i am not getting. i have had a look on the web and found some examples, but i cant see why my code does not...
5
5020
by: sfeher | last post by:
Hi All, I need to call a function(loaded with appendChild) for which I have the name as a string. .... var fnName = 'fn1'; var call = fnName + '('+ param +' )'; eval(call);
2
1967
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call that variable in another Java script. Sample script <SCRIPT LANGUAGE="JavaScript"> function GetSelectedItem() { len = document.formname.selectname.length i = 0 chosen = "none"
1
2234
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call that variable in another Java script. Sample script <SCRIPT LANGUAGE="JavaScript"> function GetSelectedItem() { len = document.formname.selectname.length i = 0 chosen = "none"
0
9618
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
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10101
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...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
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...
1
7456
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
5354
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...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
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.