String is not a function on window location href
JavascriptJqueryJavascript Problem Overview
Consider:
$('.b').click(function(){
var link = 'www.yahoo.com';
window.location.href(link);
});
I expect it to open www.yahoo.com, but it says "string is not a function". Why?
jsFiddle: http://jsfiddle.net/V9Xat/
Javascript Solutions
Solution 1 - Javascript
Try-
window.location.href = link;
or
window.location.assign(link);
Solution 2 - Javascript
Solution 3 - Javascript
window.location.href = link;
Use this.
Solution 4 - Javascript
Either use:
window.location.href = link;
Or with .replace();
:
window.location.replace(link);