Reputation: 103
If I click a button from page A, the browser will redirect to page B. In page B if I click a another button again it redirects to Page A. Here I used window.location.href
to redirect the new page.
eg:window.location.href="http:\\localhost:12345\index2.html"
Is any other alternative way to redirect next page. I don't want to use windows.location
Update:
If I use windows.location
the url which I come from is stored in document.reffer
. For security purposes I don't want to allow to store the url.
Upvotes: 0
Views: 28681
Reputation: 759
You can use location.assign() for redirect another page.
location.assign("https://www.facebook.com/");
Upvotes: 0
Reputation: 41
Using $location
in angularjs : See the documentation https://docs.angularjs.org/api/ng/service/$location
Upvotes: 1
Reputation: 4547
You may use this method example :-
function myFunction() {
location.assign("https://www.google.co.in");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Load new document</button>
</body>
</html>
Upvotes: 5
Reputation: 11
why not use <a>
. what you only to do is give it a class like button.
Upvotes: -1
Reputation: 1023
$url =$('<a/>')
$url.attr('href',"http://google.com");
$url[0].click()
You can try this.
Upvotes: 0
Reputation: 2107
You can also use
window.location.replace("http://someUrl.com");
replace() does not keep the originating page in the session history.
Upvotes: 4