How to get the browser to navigate to URL in JavaScript

0 votes
What is the best way to get a web browser to navigate to a URL of your choice using JavaScript?
May 28, 2020 in Java-Script by kartik
• 37,490 points
646 views

1 answer to this question.

0 votes

Hii,

This works in all browsers:

window.location.href = '...';

If you wanted to change the page without it reflecting in the browser back history, you can do:

window.location.replace('...');

Hope this is helpfull!

answered May 28, 2020 by Niroj
• 82,560 points

Related Questions In Java-Script

0 votes
1 answer

How to get the host url using javascript from the current page?

Hello @kartik, Use: var host = window.location.hostname; or possibly var host ...READ MORE

answered Oct 9, 2020 in Java-Script by Niroj
• 82,560 points
143 views
0 votes
1 answer

How to detect if URL has changed after hash in JavaScript?

Hello @kartik, Use this code window.onhashchange = function() { ...READ MORE

answered Jun 17, 2020 in Java-Script by Niroj
• 82,560 points
1,305 views
0 votes
1 answer

How to decode the url in php where url is encoded with encodeURIComponent()?

Hello @kartik, Use this function: <?php $string = 'http%3A%2F%2Fexample.com'; $output = ...READ MORE

answered Jul 7, 2020 in Java-Script by Niroj
• 82,560 points
1,030 views
0 votes
1 answer

How to trigger the window resize event in JavaScript?

Hello @kartik, Try this: window.dispatchEvent(new Event('resize') ...READ MORE

answered Aug 25, 2020 in Java-Script by Niroj
• 82,560 points
147 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,560 points
5,441 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,560 points
635 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,560 points
486 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,560 points
6,044 views
0 votes
1 answer

How to get the URL without any parameters in JavaScript?

Hello @kartik, This is possible, but you'll have ...READ MORE

answered Oct 9, 2020 in Java-Script by Niroj
• 82,560 points
70 views
0 votes
1 answer

How to get the current URL with JavaScript?

Hello @kartik, Use: window.location.href As noted in the comments, ...READ MORE

answered Aug 28, 2020 in Java-Script by Niroj
• 82,560 points
134 views