String is not a function on window location href [duplicate]

Solution 1:

Try-

window.location.href = link;

or

window.location.assign(link);

JSFiddle

Check out the syntax of window.location here.

Solution 2:

Try using:

window.location.href = link;

MDN source

Solution 3:

window.location.href = link;

Use this.