Reputation: 67175
The following markup is generated by my ASP.NET MVC page.
<button onclick="window.open='/Client/ReleaseForm';" type="button" class="btn btn-primary">
View/Print Release Form
</button>
However, clicking the button has no effect. No window is opened, no new tabs are opened, and no errors are shown in the console of my Chrome browser.
I know there are pop-up blockers, but I had got the impression that this worked as long as it was in response to a user action (such as clicking the button).
Can anyone tell me how I can display content in a new window?
Upvotes: 0
Views: 1278
Reputation: 174937
I'm pretty sure window.open
is a function, so you want:
window.open('/Client/ReleaseForm');
Also, it's probably even better to set an event handler in JavaScript code and not inline.
<button id="print" type="button" class="btn btn-primary">
View/Print Release Form
</button>
<!-- Elsewhere, in a JS file -->
document.getElementById('print')
.addEventListener('click', function viewOrPrintReleaseForm() {
window.open('/Client/ReleaseForm');
});
Upvotes: 2