I'm trying to make a feature where clicking on a button will load a window in a new tab. For some reason, this is not working.
In my HTML, I have
<button onClick="myFunction"> Try it </button>
and the corresponding function is
<script type="text/javascript">
function myFunction() {
window.open("http://localhost:9000/", "_blank");
}
</script>
For some more details, this is being done from a widget on Team Foundation Server and I'm trying to load a SonarQube page. This is what the page should look like, but when I try to access it with the above code it just loads a blank page. However, the proper favicon is there. If I load my HTML page normally (not on Team Foundation Server), clicking the button loads the page properly, so I think it has something to do with Team Foundation Server, but I have no clue what.
Any help would be greatly appreciated.
Thanks!
Please try to use below snippet in your HTML.
<a href="http://localhost:9000/" target="_blank">
<button>Button Name</button>
</a>
Or Java Script:
<input type="button" value="button name" onclick="window.open('http://localhost:9000/')" />
Worked for me and it will open an actual new 'popup' window rather than a new full browser or tab.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.