It'll work fine for all JavaScript compliant browsers - but people browsing with JavaScript turned off won't see the link.
Another consideration is that since the link is in the script, I don't think that SE spiders can follow it. Your code won't validate, but it will work.