473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 32111
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.