简体   繁体   English

Javascript中的重定向

[英]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. 我有以下代码,我正在尝试将页面重定向到同一页面,但链接上带有int,但它不断出现页面错误。

 var done_update = '&updated=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 . 字符串连接是在JavaScript(以及Java)中使用+而不是. :

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 . JavaScript中的字符串连接使用+运算符完成,而不是. as in other languages (Perl, PHP...) 和其他语言一样(Perl,PHP ...)

  2. location is a global variable, there is no need to specify window.location location是一个全局变量,无需指定window.location

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM