Set window.location with TypeScript
window.location
is of type Location
while .attr('data-href')
returns a string, so you have to assign it to window.location.href
which is of string type too. For that replace your following line:
window.location = $link.attr('data-href');
for this one:
window.location.href = $link.attr('data-href');
you have missed the href
:
Standard, To use window.location.href
as window.location
is technically an object containing:
Propertieshash host hostnamehref <--- you need thispathname (relative to the host)port protocol search
try
window.location.href = $link.attr('data-href');