When trying to redirect to an external page using $window.location.href
, the page is just refreshing and not redirecting to the expected URL.
Click the URL Redirects tab. In the upper right, click Add URL redirect. In the right panel, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.
The simplest way to redirect to another URL is to use an HTML <meta> tag with the http-equiv parameter set to “refresh”. The content attribute sets the delay before the browser redirects the user to the new web page. To redirect immediately, set this parameter to “0” seconds for the content attribute.
URL redirect (URL forwarding) allows you to forward your domain visitors to any URL of your choice (to a new domain or a different website). You can set 301 (Permanent), 302 (Unmasked), and Masked (URL Frame) redirects for the domain names pointed to BasicDNS, PremiumDNS or FreeDNS.
Use the window. location. replace() method to redirect to an external url in React, e.g. window. location.
<html ng-app="myApp">
<head>
</head>
<body ng-controller="myCtrl">
<p> <a href="https://www.google.co.in/"><button>Click me to redirect from template</button></a></p>
<p ng-click="myFunction()"> <button>Click me to redirect from controller</button></p>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script>
var app = angular.module('myApp',[]);
app.controller('myCtrl',function($window,$scope){
$scope.myFunction = function(){
$window.location.href = 'http://www.google.com'; //You should have http here.
}
});
</script>
</body>
</html>
This works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With