472,989 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 software developers and data experts.

How To Pass Parameters in URL for Javascript Refresh?

DCB
Hello.

I have an easy question, likely, that has me in a headspin. I have an
include file to a frames based site that basically forces frames on
the end user if they visit the site and hit a non-frames created
page...

Simply, it is:

if (parent != self)
self.parent.location.replace("/");

However, now I would like to force an inner frame to populate based on
what frame someone was redirected from the include (above). So, if I
visit http://domain/frame/innerframe_3.html, then I want to redirect
to the above, but pass in /frame/innerframe_3.html to be included as a
URL parameter for an inner frame to be populated.

When I modify this link to:

if (parent != self)
self.parent.location.replace("/index.php?redir=" & location.href);

Then, the replaced location doesn't seem to recognize the ?redir=
portion of the new location.

Is there a different way to do this? I can't use a META tag because I
want the TARGET to be _TOP, basically.

Thanks if anyone has a clue.
D.
Jul 23 '05 #1
3 32012
DCB wrote:
Hello.

I have an easy question, likely, that has me in a headspin. I have an
include file to a frames based site that basically forces frames on
the end user if they visit the site and hit a non-frames created
page...

Simply, it is:

if (parent != self)
self.parent.location.replace("/");

However, now I would like to force an inner frame to populate based on
what frame someone was redirected from the include (above). So, if I
visit http://domain/frame/innerframe_3.html, then I want to redirect
to the above, but pass in /frame/innerframe_3.html to be included as a
URL parameter for an inner frame to be populated.

When I modify this link to:

if (parent != self)
self.parent.location.replace("/index.php?redir=" & location.href);

Then, the replaced location doesn't seem to recognize the ?redir=
portion of the new location.

Is there a different way to do this? I can't use a META tag because I
want the TARGET to be _TOP, basically.

Thanks if anyone has a clue.
D.


You should probably be using: locationreplace('/index.php?redir=' +
escape(location.href)); to make sure any characters that don't belong in the
query string are encoded first.

For the replaced location to "recognize" the ?redir= portion of the new
location, you have to read it and write the <frame> tag in index.php based on
it's contents. This would be done using PHP:

<?php
$redir = $_GET['redir'];
if (!$redir) {
$redir = '/somedefault.php';
}
?>
<frameset>
....
<frame src="<?php echo $redir ?>" ... >
....
</frameset>

You really should probably do more validation on $_GET['redir'] then I've
shown, since I could load any page on your site using
/index.php?redir=somepageyoudonotwantmetosee

If the above isn't working, start simple:

<?php
$redir = $_GET['redir'];
echo $redir;
?>
<!--
<frameset>
....
</frameset>
-->

does it output the value you passed on ?redir= ?

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2
DCB
Yeah, it's really weird. It appears to me that the location.replace
ignores parameters passed into it. When I go directly to the url and
type the parameters into the URL...

http://www...com/index.php?redir=/news/index.html

then it works perfect.

However, if I go to

http://www...com/news/index.html

It will redirect to the framebuilder correctly and build the frames,
but the ?redir=/news/index.html is totally ignored... including if I
simply look for the get value in PHP and write it to the page alone.

Does location.replace ignore any GET/URL parameters?

I'm working on setting a cookie instead, but this seems like a bit of
overkill.

If anyone else has struggled with this, I'd appreciate your insight.

Thanks, Greg!

- Derek.

Grant Wagner <gw*****@agricoreunited.com> wrote in message news:<40***************@agricoreunited.com>...
DCB wrote:
Hello.

I have an easy question, likely, that has me in a headspin. I have an
include file to a frames based site that basically forces frames on
the end user if they visit the site and hit a non-frames created
page...

Simply, it is:

if (parent != self)
self.parent.location.replace("/");

However, now I would like to force an inner frame to populate based on
what frame someone was redirected from the include (above). So, if I
visit http://domain/frame/innerframe_3.html, then I want to redirect
to the above, but pass in /frame/innerframe_3.html to be included as a
URL parameter for an inner frame to be populated.

When I modify this link to:

if (parent != self)
self.parent.location.replace("/index.php?redir=" & location.href);

Then, the replaced location doesn't seem to recognize the ?redir=
portion of the new location.

Is there a different way to do this? I can't use a META tag because I
want the TARGET to be _TOP, basically.

Thanks if anyone has a clue.
D.


You should probably be using: locationreplace('/index.php?redir=' +
escape(location.href)); to make sure any characters that don't belong in the
query string are encoded first.

For the replaced location to "recognize" the ?redir= portion of the new
location, you have to read it and write the <frame> tag in index.php based on
it's contents. This would be done using PHP:

<?php
$redir = $_GET['redir'];
if (!$redir) {
$redir = '/somedefault.php';
}
?>
<frameset>
...
<frame src="<?php echo $redir ?>" ... >
...
</frameset>

You really should probably do more validation on $_GET['redir'] then I've
shown, since I could load any page on your site using
/index.php?redir=somepageyoudonotwantmetosee

If the above isn't working, start simple:

<?php
$redir = $_GET['redir'];
echo $redir;
?>
<!--
<frameset>
...
</frameset>
-->

does it output the value you passed on ?redir= ?

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html

Jul 23 '05 #3
A quick test demonstrates that window.location.replace() does indeed pass the query string as written to the
page being loaded:

<body>
<script type="text/javascript">alert(window.location.search);</script>
<form><input type="button" value="Click to see the value of redir"
onclick="window.location.replace(window.location.h ref + '?redir=this/is/a/test');">
</form></body>

I'd suggest you put together a similar simple page for PHP to demonstrate to yourself that the query string
is, in fact, arriving intact:

<body>
<?php echo $_GET['redir']; ?>
<form><input type="button" value="Click to see the value of redir"
onclick="window.location.replace(window.location.h ref + '?redir=this/is/a/test');">
</form></body>

As well, try replacing the call to window.location.replace() with alert() _without making any other changes_:

<input type="button"
onclick="alert(window.location.href + '?redir=this/is/a/test');">

This will allow you to verify that the URI to the page is being created the way you think it is. Do what I
suggested initially (and demonstrated in my test case), simply echo the value of $_GET['redir'] in index.php,
ensure it's what you think it should be.

DCB wrote:
Yeah, it's really weird. It appears to me that the location.replace
ignores parameters passed into it. When I go directly to the url and
type the parameters into the URL...

http://www...com/index.php?redir=/news/index.html

then it works perfect.

However, if I go to

http://www...com/news/index.html

It will redirect to the framebuilder correctly and build the frames,
but the ?redir=/news/index.html is totally ignored... including if I
simply look for the get value in PHP and write it to the page alone.

Does location.replace ignore any GET/URL parameters?

I'm working on setting a cookie instead, but this seems like a bit of
overkill.

If anyone else has struggled with this, I'd appreciate your insight.

Thanks, Greg!

- Derek.

Grant Wagner <gw*****@agricoreunited.com> wrote in message news:<40***************@agricoreunited.com>...
DCB wrote:
Hello.

I have an easy question, likely, that has me in a headspin. I have an
include file to a frames based site that basically forces frames on
the end user if they visit the site and hit a non-frames created
page...

Simply, it is:

if (parent != self)
self.parent.location.replace("/");

However, now I would like to force an inner frame to populate based on
what frame someone was redirected from the include (above). So, if I
visit http://domain/frame/innerframe_3.html, then I want to redirect
to the above, but pass in /frame/innerframe_3.html to be included as a
URL parameter for an inner frame to be populated.

When I modify this link to:

if (parent != self)
self.parent.location.replace("/index.php?redir=" & location.href);

Then, the replaced location doesn't seem to recognize the ?redir=
portion of the new location.

Is there a different way to do this? I can't use a META tag because I
want the TARGET to be _TOP, basically.

Thanks if anyone has a clue.
D.


You should probably be using: locationreplace('/index.php?redir=' +
escape(location.href)); to make sure any characters that don't belong in the
query string are encoded first.

For the replaced location to "recognize" the ?redir= portion of the new
location, you have to read it and write the <frame> tag in index.php based on
it's contents. This would be done using PHP:

<?php
$redir = $_GET['redir'];
if (!$redir) {
$redir = '/somedefault.php';
}
?>
<frameset>
...
<frame src="<?php echo $redir ?>" ... >
...
</frameset>

You really should probably do more validation on $_GET['redir'] then I've
shown, since I could load any page on your site using
/index.php?redir=somepageyoudonotwantmetosee

If the above isn't working, start simple:

<?php
$redir = $_GET['redir'];
echo $redir;
?>
<!--
<frameset>
...
</frameset>
-->

does it output the value you passed on ?redir= ?


--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #4

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

Similar topics

0
by: Scott Townsend | last post by:
I'd like to pass parameters to a local Application from a webpage. something like: <a href="file:///C:/Program%20Files/myapp/myapp.exe%20-custno:mycustno%20-quote no:12345%20-item:12345">test...
13
by: Al Franz | last post by:
Anyone understand how to pass parameters to a JavaScript. If anyone finds this easy to do maybe they could take a look at my short script on this page and show me how it needs to be changed. ...
5
by: Ben | last post by:
Hi I am using a User Control which is referenced by an ASPX page. How can I pass a string parameter to the user control, from the base ASPX page. Thanks Ben
6
by: Woody Splawn | last post by:
I am using SQL Server 2000 as a back-end to a VS.net Client/Server app. In a certain report I use a view as part of the query spec. For the view, at present, I am querying for all the records in...
3
by: Wang Xiaoning | last post by:
I have an customerdetail.xsl sheet ---------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"...
3
by: Joseph Lu | last post by:
Hi, all I have a stored procedure created in SQL Server like the following lines. // stored proceudre code starts here CREATE PROCEDURE sp_insertdata @strdata varchar(250) , @rsult BIT...
0
by: raghuraman_ace | last post by:
Hi i have started a webservice wich has a webmethod with parameters using literal encoding & encoded encoding . The webservice is compiled successfully . But i don know how to pass the...
1
by: eldokp | last post by:
hi, In my javaScript function iam using document.ReportListForm.submit(); for form submision My ReportListForm contains <form name="RoleListForm" method="Post"...
0
by: PriyaManasarovar | last post by:
Can someone help how to pass parameters to a crystal report using a Crystal report object? I am using a console application & hence crystal report viewer cannot be used. And i need to pass the...
3
by: Vajrala Narendra | last post by:
Hi all Hi all, In my WF Project i have a CodeActivity, that is to check wether entered userid, password are valid or not how to pass parameters to CodeActivity. what i tried is in my class i...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.