String is not a function on window location href

javascript, jquery

Solution

Try-

window.location.href = link;

or

window.location.assign(link);

JSFiddle

Check out the syntax of window.location here.

Problem

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/

Original source

Related problems