473,513 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript sending variable

Dan
Hi,

Is there a way to send a variable to a different page that it is
redirecting to? For example,

<script type="text/javascript">

var o;
if ( (o = top)
&& (o = o.frames)
&& (o = o.bob)
&& (o = o.document)
&& (o = o.title)
&& o == "test"
){
document.write("yes")
} else {
document.location.href = "New Text Document.php "
}
</script>

If it is false, I would like it to set a variable that it will send to
the page "New Text Document.php" (that it is redirecting to). Is this
possible?

Dan

Nov 30 '05 #1
2 1511
Dan wrote:
<script type="text/javascript">
var o;
if ( (o = top)
&& (o = o.frames)
&& (o = o.bob)
&& (o = o.document)
&& (o = o.title)
&& o == "test"
Looks like my code, although I would have spared the last assignment :)
){
document.write("yes")
} else {
document.location.href = "New Text Document.php " ^ ^ ^
Err, spaces are _not_ allowed within URIs.
}
</script>

If it is false, I would like it to set a variable that it will send to
the page "New Text Document.php" (that it is redirecting to). Is this
possible?


Sure,

document.location.href =
"New%20Text%20Document.php?name1=value1&name2=valu e2";

(or use concatenation and escape/encodeURIComponent.)

In PHP, you use the $_GET superglobal (PHP >= 4.1) or
$HTTP_GET_VARS (PHP < 4.1), with safer register_globals=off.

I wonder why you did not use much more reliable server-side
redirection in the first place:

<URL:http://www.w3.org/QA/Tips/reback>
PointedEars
Nov 30 '05 #2
Thomas 'PointedEars' Lahn wrote:
Dan wrote:
document.location.href = "New Text Document.php "

[...]
document.location.href =
"New%20Text%20Document.php?name1=value1&name2=valu e2";


`document.location(.href)' is deprecated long
since, use window.location' or just `location'.
PointedEars
Nov 30 '05 #3

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

Similar topics

5
1925
by: Ken | last post by:
How do I send a variable, $validity from php and use it in JavaScript? Seem like PHP is written first, then html and JavaScript. Is it possible? Ken
6
13804
by: Geoff | last post by:
Here's the situation. I have a static html page which we want to update to include some dynamic content. I want a counter that keeps track of the number of times anyone presses the "add" button,...
2
2148
by: brianwmunz | last post by:
Hi, I'm having a problem passing a variable through a URL because the variable is supposed to hold a URL that has a variable of its own. Here is an idea of what I'm trying to do: href="javascript:...
3
5699
by: mbasil7 | last post by:
Hi at all! I want to use a javascript variable in php. The reason is that i want to know the client's screen resolution. Keep in mind that i am not a javascript programmer but php. Here is...
2
2602
by: Chris | last post by:
I am new to these forums and hope I am in the right place! I am working on an ASP (3.0) page that displays hotel data from a recordset in a table. In the last column of each row, I want to...
6
1351
by: Nick Goloborodko | last post by:
Hi, What is the best way to detect JavaScript and Cookie support of the end user browser? TIA -- Kind regards, Nick Goloborodko
3
9638
by: jonnyblazed | last post by:
Okay..... I'm gonna sum up what I want to do cause it will make it pretty simple for you guys to understand. Here we go: I have a form that posts data to a PHP mailer page I have created. When...
0
1155
by: Jesper Lund Stocholm | last post by:
I have problems with sending javascript to the client from a dynamically loaded usercontrol. I have a single page that dynamically loads controls into a table cell in a HTML-table. For one of...
3
2414
by: BAnderton | last post by:
Hello all, Question: Is there any way to access a javascript variable from within psp code? I'm aware of how to do the reverse of this (js_var='<%=psp_var%>'). Here's a non-working...
0
7264
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,...
0
7166
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...
0
7386
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,...
1
7106
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...
0
5689
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,...
1
5094
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...
0
4749
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...
0
1601
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 ...
0
459
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...

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.