window.location.href
is not a method, it’s a property that will tell you the current URL location of the browser. Changing the value of the property will redirect the page.
window.open()
is a method that you can pass a URL to that you want to open in a new window. For example:
window.location.href example:
window.location.href = 'http://www.google.com'; //Will take you to Google.
window.open() example:
window.open('http://www.google.com'); //This will open Google in a new window.
Additional Information:
window.open()
can be passed additional parameters. See: window.open tutorial
Related Posts:
- Open URL in same window and in same tab
- JavaScript function in href vs. onclick
- anchor jumping by using javascript
- window.location.replace() not working to redirect browser
- How to change href of tag on button click through javascript
- What is TypeScript and why would I use it in place of JavaScript? [closed]
- How to do associative array/hashing in JavaScript
- map function for objects (instead of arrays)
- Check if a string has a certain piece of text [duplicate]
- Is it possible to sandbox JavaScript running in the browser?
- jQuery: Wait/Delay 1 second without executing code
- How to play audio?
- How do I test for an empty JavaScript object?
- Tallest Unicode character?
- How to solve ‘Redirect has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header’?
- Generating random whole numbers in JavaScript in a specific range?
- Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag
- Nested JSON objects – do I have to use arrays for everything?
- How to find the sum of an array of numbers
- JavaScript null check
- keep getting “? Something is already running on port 3000” when I do npm start on react app
- React Context vs React Redux, when should I use each one?
- Regular expression : match either of two conditions?
- jQuery AJAX submit form
- Difference between this and self in JavaScript
- HTML5 Local storage vs. Session storage
- Expressjs / Node.js – res.redirect() not loading page
- Using async/await with a forEach loop
- How to check if two arrays are equal with JavaScript?
- Vue is not defined
- How to remove all listeners in an element?
- How do I check if an object has a key in JavaScript?
- How to add a “readonly” attribute to an ?
- JQuery $(“#content”).append not working
- What is the difference between null and undefined in JavaScript?
- use Lodash to sort array of object by value
- Chrome/jQuery Uncaught RangeError: Maximum call stack size exceeded
- Counting words in string
- What’s “this” in JavaScript onclick?
- how to use react require syntax?
- document.getElementById(id).focus() is not working for firefox or chrome
- How to get height of div in px dimension
- How to get unique values in an array
- How to fix Error: listen EADDRINUSE while using NodeJS?
- How to allow CORS in react.js?
- Only on Firefox “Loading failed for the script with source”
- How do you use a variable in a regular expression?
- How to embed a youtube playlist with a sidebar
- How to add a button dynamically using jquery
- Function overloading in Javascript – Best practices
- Wait until flag=true
- momentJS date string add 5 days
- When is a CDATA section necessary within a script tag?
- How to get scrollbar position with Javascript?
- where is create-react-app webpack config and files?
- “You may need an appropriate loader to handle this file type” with Webpack and Babel
- How to create checkbox inside dropdown?
- Find a value in an array of objects in Javascript [duplicate]
- How to wrap the content of the main tinyMCE editor with extra tags
- How to handle malformed response from WP REST API?
- Javascript not working?
- Add Item to Custom TinyMCE Menu
- Modals using loops and ACF [closed]
- Changes to JS not reflected on site
- How do developers add “Smooth Transitions” to their sites?
- Exclude JS file from 404 error page
- Pass data from wordpress to javascript in JSON
- How to make wordpress URLS google friendly for ajax driven sites?
- How can I get my Calculate Contact Form 7 field to update with jQuery? [closed]
- Contact Form 7 – Uncaught TypeError: wpcf7.initForm is not a function [closed]
- js addclass function not working as expected, intereaction or special WP somethign needed?
- Where is script-loader.php creating JS tags
- WP TinyMCE (Full + media ) – 4.8 JS Init Dynamicly
- Get a default value of the Customizer setting using wp.customize API (JS)
- Google PageSpeed Enable Compression isn’t working?
- Search for a keyword across post types in a Gutenberg component
- Calling a WordPress Custom JavaScript file
- print script on wordpress header after user registered
- How do I use this javascript correct with wordpress?
- Load external javascript files
- Javascript alert appears before tag
- Bootstrap bundle present in page source but not working
- Multiple jQuery inputs or binds in Customizer Control Javascripts
- How to display different content on the same page using different URLS
- Web cover page open when button clicked
- Replace script attr or link
- Remove escape characters from JSON string pulled from a database
- How to pass data to javascript in custom widget class
- Immediate (e.g. without DOMContentLoaded) JS not working
- Client side pre-save Javascript hook on all admin pages
- WP Gutenberg – custom block with two content fields
- How to identify which javascript is being executed
- How to add additional JavaScript code [duplicate]
- How to keep close a sub-menu under homepage? [closed]
- How to implement custom URL handler to access JS modal content? [closed]
- Contact form 7 hide and show fields depending up on the condition [closed]
- Javascript 2 elements dependent onclick .toggle [closed]
- wp_enqueue has a resource but doesn’t generate a script tag [duplicate]
- Javascript not working on index.php but it is working on single post’s page
- Unable to change the location of a file