Under IE and Firefox, the behavior of a tag using href=”javascript:void(0);” and target=”_blank” is not as expected

Found in the development today, use the link in the following way. Behaviour as expected after click in Chrome, but open new tabs under IE (same issue in Firefox according to references).
<a href=”javascript:void(0);” target=”_blank”>test</a>

After searching for information, it is found that the following solutions are required.
Block browser default events via onclick: <a onclick=”return false;” href=”javascript:void(0);” target=”_blank”>test</a>
or directly: <a target=”_blank”> test</a>

The reason is that the three browsers process the three properties in different order.
Chrome order: onclick -> href -> target
IE and Firefox order: onclick -> target -> href


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326860613&siteId=291194637