screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3>Vue Js Change/modify URL without reloading the page</h3> <button @click="updateURL">Change URL</button> <div> <p>{{ url }}</p> </div> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { url: '' }; }, mounted() { const initialURL = window.location; this.url = `Current Url: ${initialURL}` }, methods: { updateURL() { const newURL = '/new-url'; window.parent.history.pushState({}, '', newURL); const changedUrl = window.parent.location; this.url = `Changed Url: ${changedUrl}` }, } }); </script> <style scoped> #app { text-align: center; padding: 20px; } h3 { color: #333; font-size: 24px; margin-bottom: 10px; } button { padding: 10px 20px; background-color: #007bff; color: #fff; border: none; cursor: pointer; font-size: 16px; border-radius: 4px; transition: background-color 0.3s ease; } button:hover { background-color: #0056b3; } div { margin-top: 20px; } h1 { font-size: 32px; color: #333; margin-bottom: 10px; } p { font-size: 18px; color: #555; line-height: 1.5; } </style> </body> </html>