views:

37

answers:

3

I Have the following code i am trying to redirect the page to the same page but with a int on the link but it keeps coming up with page error.

 var done_update = '&updated=1';
 window.location = window.location.href.done_update;

Thank you,

+2  A: 

String concatenation is done in JavaScript (and Java for that matter) using a + and not a .:

var done_update = '&updated=1';
window.location = window.location.href + done_update;
amphetamachine
First!!!!!!!!!!
amphetamachine
+2  A: 
var done_update = '&updated=1';
window.location = window.location.href+done_update;
aularon
+1  A: 
var done_update = "&update=1";
location = location.href + done_update;
  1. String concatenation in JavaScript is done using the + operator, not . as in other languages (Perl, PHP...)

  2. location is a global variable, there is no need to specify window.location

adamse
I would say 2 is a personal preference. I almost always use an explicit reference to window objects and properties, there's no risk of overriding them in local scopes that way.
Andy E
If you put it that way it is reasonable to use `window.location`. However all global variables are properties of `window`, do you also use `window.document`?
adamse