Rickstar
Rickstar

Reputation: 6199

Redirection in Javascript

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,

Upvotes: 0

Views: 256

Answers (3)

ase
ase

Reputation: 13491

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

Upvotes: 1

aularon
aularon

Reputation: 11110

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

Upvotes: 2

amphetamachine
amphetamachine

Reputation: 30621

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;

Upvotes: 2

Related Questions