Vue.js Close Window
We can use native JavaScript .close() property to close the current open window. Here in this tutorial, We are going to explain how you can close the current open window in Vuejs. You can use our online editor to edit and close the current window.
Vue.js Close Window Example
Here is an example of open and close the current window-
Example:
<div id="app"> <button @click="openWindow()">Open Window</button> <br> <button @click="closeWindow()">Close Window</button> </div> <script> new Vue({ el: '#app', data: { myWindow : '' }, methods:{ openWindow: function () { this.myWindow = window.open("", "myWindow", "width=500,height=300"); this.myWindow.document.write("<h1>www.tutorialsplane.com</h1>"); }, closeWindow: function () { this.myWindow.close(); } } }); </script> |
Advertisements