Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  125] [ 6]  / answers: 1 / hits: 72046  / 10 Years ago, wed, july 9, 2014, 12:00:00

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/


More From » jquery

 Answers
44

Try-



window.location.href = link;


or



window.location.assign(link);


JSFiddle



Check out the syntax of window.location here.


[#70267] Monday, July 7, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jonrened

Total Points: 627
Total Questions: 114
Total Answers: 99

Location: Zimbabwe
Member since Thu, Jul 21, 2022
2 Years ago
;