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

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/

Answers:

Answer

Try-

window.location.href = link;

or

window.location.assign(link);

JSFiddle

Check out the syntax of window.location here.

Answer

Try using:

window.location.href = link;

MDN source

Answer
window.location.href = link;

Use this.

Answer

Either use:

window.location.href = link;

Or with .replace();:

window.location.replace(link);

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.