SeguirBlog I don't think that would work.
You could generate the URL with 'https://twitter.com/intent/tweet?text=&url=' + encodeURIComponent(window.location.href)
, this returns a string.
If you are building your HTML with javascript, you can assign that string as the link href
value.
If you must use entirely inline javascript, you could use one of:
href="javascript:window.open('https://twitter.com/intent/tweet?text=&url=' + encodeURIComponent(window.location.href), '_blank')"
or
onclick="window.open('https://twitter.com/intent/tweet?text=&url=' + encodeURIComponent(window.location.href), '_blank')"
If using onclick
together with a a
, you'd need to not include href
, which might not be semantically correct. Best to use a button
or div
with ideally aria-
tags to describe its purpose.