samuel toh samuel toh - 1 year ago 74
Javascript Question

How to solve "Uncaught TypeError: restVar.reload is not a function"?

My url is like this :

My function javascript is like this :

reloadMessage() {
setTimeout(function () {
var vars = location.href;
var arrVars = vars.split("/");
var lastVar = arrVars.pop();
var lastVar = arrVars.pop();
var restVar = arrVars.join("/");
}, 1500);

I want when call reloadMessage function, it will reload page to url :

But it does not work

There exist error like this :

Uncaught TypeError: restVar.reload is not a function

How can I solve it?

Update :

If I do :
, the result :

When call reloadMessage function, I want it will reload page / url :

Answer Source

Your code that declares restVar:

var restVar = arrVars.join("/");

Returns an array, which wouldn't have 'reload()' available as a function. After you get your new URL, you might try window.location (

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download