开发者

Redirection in Javascript

开发者 https://www.devze.com 2023-01-14 16:11 出处:网络
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.

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 = '&update开发者_JAVA技巧d=1';
 window.location = window.location.href.done_update;

Thank you,


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;


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号