windows.location won't refresh on change...

  • Thread starter Christopher.Eckman
  • Start date
C

Christopher.Eckman

Hello,

I am trying to do a function to force a redirect with new query string
(depending on when a user clicks a radio button so it triggers on
onClick). When I call the function I can see (in Firebug) it sets the
new query string variable correctly but the page won't refresh or set
the new URL. I set the query string with:

var queryString = "?Dealer="+Trim(dealer)+"&seed="+Math.random();

I added the seed value to ensure this wasn't a cache problem. Anyhow,
when I call:

window.location.search = queryString;

it ignores the command. You can see it hit the command in Firebug and
the arguments are as expected but it does nothing. If I build out the
complete URL and set:

window.location.href = newURL;

That will also do nothing. This is happening for both Firefox 2 and
IE 7 on a Windows XP box. Is there something I'm missing or some
standard browser setting that blocks this?

Any insight would be appreciated,

--Chris
 
L

Lee

(e-mail address removed) said:
Hello,

I am trying to do a function to force a redirect with new query string
(depending on when a user clicks a radio button so it triggers on
onClick). When I call the function I can see (in Firebug) it sets the
new query string variable correctly but the page won't refresh or set
the new URL. I set the query string with:

var queryString = "?Dealer="+Trim(dealer)+"&seed="+Math.random();

I added the seed value to ensure this wasn't a cache problem. Anyhow,
when I call:

window.location.search = queryString;

it ignores the command. You can see it hit the command in Firebug and
the arguments are as expected but it does nothing. If I build out the
complete URL and set:

window.location.href = newURL;

That will also do nothing. This is happening for both Firefox 2 and
IE 7 on a Windows XP box. Is there something I'm missing or some
standard browser setting that blocks this?

Post a simplified version of your page that shows this problem.
My initial suspicion is that you're somehow submitting a form
(ie, causing the page to reload) unintentionally.

Your example shouldn't be much more involved than the following,
except that this version works as expected:

<html>
<head>
<title>Demo</title>
<script type="text/javascript">
function go() {
var queryString = "?Dealer=foo&seed="+Math.random();
window.location.search=queryString;
}
</script>
</head>
<body>
<form>
<input type="radio" name="alpha" onclick="go()">
<input type="radio" name="alpha" onclick="go()">
</form>
</body>
</html>


--
 
C

Christopher.Eckman

(e-mail address removed) said:











Post a simplified version of your page that shows this problem.
My initial suspicion is that you're somehow submitting a form
(ie, causing the page to reload) unintentionally.

Your example shouldn't be much more involved than the following,
except that this version works as expected:

<html>
<head>
<title>Demo</title>
<script type="text/javascript">
function go() {
var queryString = "?Dealer=foo&seed="+Math.random();
window.location.search=queryString;
}
</script>
</head>
<body>
<form>
<input type="radio" name="alpha" onclick="go()">
<input type="radio" name="alpha" onclick="go()">
</form>
</body>
</html>

--

Hi Lee,

This is a very complicated page but it boils down to this:

<html>
<head>
<title>Canon e-Support Center</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language='JavaScript' src='../javascript.js'></script>




<table width="100%" cellpadding="0" cellspacing="0"
name="dealers" id="tlist">
<tr>
<th width="7%" nowrap>&nbsp;</th>
<th width="20%" nowrap>Dealer Code </th>
<th width="38%">Company</th>
<body>
<th width="35%">City</th>
</tr>

<tr>
<td><input name="loc_list" type="radio" value="1"
onclick="setLocation(this)"></td>

<td>FOO SOLUTIONS-N. OHIO </td>
<td>NORTHWOOD </td>
</tr>
<tr>
<td><input name="loc_list" type="radio" value="2"
onclick="setLocation(this)"></td>

<td><b>A191 </b></td>
<td>WIDGET WEST PA </td>
<td>PITTSBURGH </td>

</tr>
<form name="form1" method="get"
action="changespecialist.jsp" onSubmit="return
validateSpecialist(this);">
<em:specialties>
</em:specialties>
<div class="formbtns">
<input name="Info" type="hidden" id="Info" value ="">
<input name="Row" type="hidden" id="Row" value="">
<input name="Modify" type="submit" id="Modify"
value="Modify">
</div>
</form>
</body>
</html>

The radio button is corresponds to values in a table row so I pass
this to get the context so I can get the associated values.

Thanks,

--Chris
 
L

Lee

(e-mail address removed) said:
Hi Lee,

This is a very complicated page but it boils down to this:

<html>
<head>
<title>Canon e-Support Center</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language='JavaScript' src='../javascript.js'></script>




<table width="100%" cellpadding="0" cellspacing="0"
name="dealers" id="tlist">
<tr>
<th width="7%" nowrap>&nbsp;</th>
<th width="20%" nowrap>Dealer Code </th>
<th width="38%">Company</th>
<body>
<th width="35%">City</th>
</tr>

<tr>
<td><input name="loc_list" type="radio" value="1"
onclick="setLocation(this)"></td>

<td>FOO SOLUTIONS-N. OHIO </td>
<td>NORTHWOOD </td>
</tr>
<tr>
<td><input name="loc_list" type="radio" value="2"
onclick="setLocation(this)"></td>

<td><b>A191 </b></td>
<td>WIDGET WEST PA </td>
<td>PITTSBURGH </td>

</tr>
<form name="form1" method="get"
action="changespecialist.jsp" onSubmit="return
validateSpecialist(this);">
<em:specialties>
</em:specialties>
<div class="formbtns">
<input name="Info" type="hidden" id="Info" value ="">
<input name="Row" type="hidden" id="Row" value="">
<input name="Modify" type="submit" id="Modify"
value="Modify">
</div>
</form>
</body>
</html>

The radio button is corresponds to values in a table row so I pass
this to get the context so I can get the associated values.

It looks to me like the relevent part of the code is below,
but we need to know what the setLocation() function actually
looks like. Apparently, it's defined in the file "javascript.js",
which we haven't seen.


<html>
<head>
<title>Demo</title>
<script type="text/javascript">
function setLocation(radio) {
var queryString = "?Dealer="+radio.value+"&seed="+Math.random();
window.location.search=queryString;
}
</script>
</head>
<body>
<input name="loc_list"
type="radio"
value="1"
onclick="setLocation(this)">
<input name="loc_list"
type="radio"
value="2"
onclick="setLocation(this)">
</body>
</html>


--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top