473,796 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setting window size and php

I'm rather new in JavaScript, but I have some experience in php.
I learned it's rather easy to open a window of a specified size with
JavaScript, that you need to specify the opened file, but I don't see
how to do that in php.
The file I want to open is "detail.php?ite m=$item". This generates a
query, which results in a table of at most 5x3 items. I want a window
size that is of an appropriate size. I tried:
<HEAD>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">
<!--
function NewWindow() {
window.open("de tail.php?item=$ item", "new", "width=500, height=300");
}
//-->
</SCRIPT>
- - - -
</HEAD>
and as hyperlink
<A HREF="detail.ph p?item=$item" TARGET="new" onClick="NewWin dow();
return false;">details </A>

As a matter of fact I tried in the header more than just the example
shown, but no result. With this I came closest, getting a message that
my SQL syntax was wrong. Which isn't.

I also tried setting the window size within the details.php. But then
all windows became of the same size.

I know that php is server-side and JavaScript is client-side.

Any help or hint will be appreciated.
Annette
Sep 29 '08 #1
3 2444

Annette Block schreef:

Hi Annette,
I'm rather new in JavaScript, but I have some experience in php.
I learned it's rather easy to open a window of a specified size with
JavaScript, that you need to specify the opened file, but I don't see
how to do that in php.
Well, you let PHP just put in the right values for JavaScript to use.
The file I want to open is "detail.php?ite m=$item". This generates a
query, which results in a table of at most 5x3 items. I want a window
size that is of an appropriate size. I tried:
<HEAD>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">
Leave out LANGUAGE="JavaS cript".

<!--
Stop using the <!-- also. ;-)

function NewWindow() {
window.open("de tail.php?item=$ item", "new", "width=500, height=300");
}
//-->
</SCRIPT>
- - - -
</HEAD>
and as hyperlink
<A HREF="detail.ph p?item=$item" TARGET="new" onClick="NewWin dow();
return false;">details </A>
Excactly.
And you don't want $item of course, you want its value.

So why don't you put it there? Like this:
<A HREF="detail.ph p?item=<?php echo $item; ?>" TARGET="new"
onClick="NewWin dow(); return false;">details </A>

>
As a matter of fact I tried in the header more than just the example
shown, but no result. With this I came closest, getting a message that
my SQL syntax was wrong. Which isn't.
That means more is wrong.
I bet your SQL is vunurable to SQL injection.
If you from PHP take a value from the user, theat it like dangerous
stuff that will try to corrupt your database. Never trust it.

SO, do this:
$itemPassed = (int)$_GET["item"];
when you expect an integer.

If you expect a string, make sure you escape it well before feeding to
your database.
It is VERY EASY to pass a value that will delete everything in your
database.

Google for SQL injection for more info.

>
I also tried setting the window size within the details.php. But then
all windows became of the same size.
SInce you didn't show us code that should do that, we cannot possibly
comment on it.
>
I know that php is server-side and JavaScript is client-side.
Yes.
>
Any help or hint will be appreciated.
Annette
Regards,
Erwin Moller
--
=============== =============
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
=============== =============
Sep 29 '08 #2
On Mon, 29 Sep 2008 13:22:57 +0200 wrote Erwin Moller
<Si************ *************** *************** @spamyourself.c om>:
>
Annette Block schreef:

Hi Annette,
>I'm rather new in JavaScript, but I have some experience in php.
I learned it's rather easy to open a window of a specified size with
JavaScript, that you need to specify the opened file, but I don't see
how to do that in php.

Well, you let PHP just put in the right values for JavaScript to use.
>The file I want to open is "detail.php?ite m=$item". This generates a
query, which results in a table of at most 5x3 items. I want a window
size that is of an appropriate size. I tried:
<HEAD>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">

Leave out LANGUAGE="JavaS cript".

><!--

Stop using the <!-- also. ;-)

>function NewWindow() {
window.open("d etail.php?item= $item", "new", "width=500, height=300");
}
//-->
</SCRIPT>
- - - -
</HEAD>
and as hyperlink
<A HREF="detail.ph p?item=$item" TARGET="new" onClick="NewWin dow();
return false;">details </A>

Excactly.
And you don't want $item of course, you want its value.

So why don't you put it there? Like this:
<A HREF="detail.ph p?item=<?php echo $item; ?>" TARGET="new"
onClick="NewWi ndow(); return false;">details </A>

>>
As a matter of fact I tried in the header more than just the example
shown, but no result. With this I came closest, getting a message that
my SQL syntax was wrong. Which isn't.

That means more is wrong.
I bet your SQL is vunurable to SQL injection.
If you from PHP take a value from the user, theat it like dangerous
stuff that will try to corrupt your database. Never trust it.

SO, do this:
$itemPassed = (int)$_GET["item"];
when you expect an integer.

If you expect a string, make sure you escape it well before feeding to
your database.
It is VERY EASY to pass a value that will delete everything in your
database.

Google for SQL injection for more info.

>>
I also tried setting the window size within the details.php. But then
all windows became of the same size.

SInce you didn't show us code that should do that, we cannot possibly
comment on it.
>>
I know that php is server-side and JavaScript is client-side.

Yes.
>>
Any help or hint will be appreciated.
Annette

Regards,
Erwin Moller
Thank you, Erwin.
Your tips were very helpful. Now I get a window of the right size,
that is in IE. In Firefox it is still a whole page, but I prefer to
count my blessings.
I'm aware of the danger of getting wrong input. In this case the user
can only click on a number and, if he /she wishes so, more details and
backgrounds are given.
However a strange thing happened. I got an error message saying that
there is an unknown column '$item' in 'where clause'. Of course there
is a column called 'item'. Somehow the value is not transferred. This
is also strange as I get no signal about when moving the mouse over
the hyperlink. I guess this is PHP, so I trust I'll manage sooner or
later. But thanks for your help.
Regards,
Annette
Sep 29 '08 #3

Annette Block schreef:
On Mon, 29 Sep 2008 13:22:57 +0200 wrote Erwin Moller
<Si************ *************** *************** @spamyourself.c om>:
>Annette Block schreef:

Hi Annette,
>>I'm rather new in JavaScript, but I have some experience in php.
I learned it's rather easy to open a window of a specified size with
JavaScript, that you need to specify the opened file, but I don't see
how to do that in php.
Well, you let PHP just put in the right values for JavaScript to use.
>>The file I want to open is "detail.php?ite m=$item". This generates a
query, which results in a table of at most 5x3 items. I want a window
size that is of an appropriate size. I tried:
<HEAD>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaS cript">
Leave out LANGUAGE="JavaS cript".

>><!--
Stop using the <!-- also. ;-)

>>function NewWindow() {
window.open(" detail.php?item =$item", "new", "width=500, height=300");
}
//-->
</SCRIPT>
- - - -
</HEAD>
and as hyperlink
<A HREF="detail.ph p?item=$item" TARGET="new" onClick="NewWin dow();
return false;">details </A>
Excactly.
And you don't want $item of course, you want its value.

So why don't you put it there? Like this:
<A HREF="detail.ph p?item=<?php echo $item; ?>" TARGET="new"
onClick="NewWi ndow(); return false;">details </A>

>>As a matter of fact I tried in the header more than just the example
shown, but no result. With this I came closest, getting a message that
my SQL syntax was wrong. Which isn't.
That means more is wrong.
I bet your SQL is vunurable to SQL injection.
If you from PHP take a value from the user, theat it like dangerous
stuff that will try to corrupt your database. Never trust it.

SO, do this:
$itemPassed = (int)$_GET["item"];
when you expect an integer.

If you expect a string, make sure you escape it well before feeding to
your database.
It is VERY EASY to pass a value that will delete everything in your
database.

Google for SQL injection for more info.

>>I also tried setting the window size within the details.php. But then
all windows became of the same size.
SInce you didn't show us code that should do that, we cannot possibly
comment on it.
>>I know that php is server-side and JavaScript is client-side.
Yes.
>>Any help or hint will be appreciated.
Annette
Regards,
Erwin Moller

Thank you, Erwin.
Your tips were very helpful. Now I get a window of the right size,
that is in IE. In Firefox it is still a whole page, but I prefer to
count my blessings.
I'm aware of the danger of getting wrong input. In this case the user
can only click on a number and, if he /she wishes so, more details and
backgrounds are given.
However a strange thing happened. I got an error message saying that
there is an unknown column '$item' in 'where clause'. Of course there
is a column called 'item'. Somehow the value is not transferred. This
is also strange as I get no signal about when moving the mouse over
the hyperlink. I guess this is PHP, so I trust I'll manage sooner or
later. But thanks for your help.
Regards,
Annette
Hi Annette,

A few tips about debugging that helped me a lot:
1) When debugging HTML, always FIRST do a 'view source' of the results
PHP sent you. Simply check if all the things you want in the page are
put there with their right values.
2) When debugging postings/requests from a browser to PHP, simply do this:

echo "<pre>";
print_r($_POST) ;
echo "</pre>";
exit;

Or $_GET, or whatever you want to see.
That way you can easily see WHAT the browser is sending you.

Best of luck.
If you need more help with PHP: comp.lang.php

Regards,
Erwin Moller

--
=============== =============
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
=============== =============
Sep 30 '08 #4

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

Similar topics

5
8310
by: Laura | last post by:
Hello, Newbie question: Does anyone know how to dynamically set the screen width in an applet? I have an applet that creates a horizontal bar menu on a webpage, and I would like the width to be 100%. Unfortunately, this doesn't work with Explorer. so, in my html page, I wrote a function like this: <SCRIPT LANGUAGE="JavaScript"> int function getScreenWidth()
2
12792
by: Put 030516 in email subj to get thru | last post by:
I've always been bothered about having to statically declare the size of a Java applet window (container?) in the calling HTML. I've always wanted the moral equivalent of width=50% statement (of the window or frame). I'm trying to use Javascript to do so. I can sort of get an example working in a Mozilla browser: > <!-- This works on Mozilla only (and maybe netscape) --> > <script language="Javascript"> > document.write( "<applet...
2
11131
by: Hasan Ammar | last post by:
Is it possible to set up hotkeys using onkeypress? I know it can be done with the usual alphanumeric keys, but what about function keys? or using ctrl/alt combinations? Does anybody have a tutorial/guide?
21
3993
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
0
1491
by: jkristia | last post by:
I'm completely lost right now, and can't figure out how to solve this problem. I want my app and dialogs to show up in the same position and same size as when they were closed. For that I do the following. In the constructor I call Util.LoadPosition(control) which reads in the position and size
4
6179
by: BrianKE | last post by:
I am attempting to create an app that will run "on top" of another app. My app will create a transparent window over the other app for the purpose of displaying information. I am able to create my transparent app but cannot get the size and position of the other app. I can get the handle of the other app using the DllImport("user32")...FindWindow method. However, when I try to get this size/position of this other window using...
1
1423
by: DBC User | last post by:
I came across the application setting feature today and it is pretty cool. I would like to know if someone can help me in the following situation. In my current project, On form closing I take the current size of the windows form and its position and store them as serialized object per user. Next time when the user login in, I read corresponding serialized object and show the windows as when they last exist. It looks like application...
2
2060
by: jodleren | last post by:
Hi! I am making an option, which opens a small window with a picture in it and data about it. I just want a JS script, which will get the picture size, and then set the window accordingly? BR Sonnich
7
32120
by: John Fox | last post by:
Dear All, How do I set the size of the window that is showing the database forms? can't find any helps on it. John Fox
0
9685
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
10461
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
10239
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
10190
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
10019
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
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4122
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
2928
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.