Hi I want to navigate from one page to another without ajax. With ajax we can use $.mobile.changePage('test.html') But I am targeting blackberry5+ version. Instead of window.location and <a href="test.html"> is there is any other option available. Any suggestion will be appreciated.
try:
window.location.href = "test.html";
OR:
window.location.assign("test.html");
window.location.replace("test.html");
Not sure I understand but onclick="setLocation('newurl.html');" is another method?
Related
I have a url to a api which shows json. I want to be able to click that json and if i press the back button/ custom button, the browser will kinowthe previous state of the url.
Im not sure how to properly use the $location attribute in angular to to do that.
Thanks in advance.
If you want something very simple just try
$scope.backBtnClick = function() {
window.history.back();
};
If I have a site "http://example.com/" is it possible to show in the URL (after loading the page) "bananas" instead of "http://example.com/"?
No, this is not possible without redirecting to another page.
This isnt possible with a redirect. You cant do it anywhere
Closest you can get is window.location.hash = "bananas"; which produces http://example.com/#bananas.
Would need to know the selector button to return to the previous page, for jquery or javascript.
to be understood would be something like:
('back-button').click(function(){
});
I want this and I need that when you click back to return to the home of my web.
Thank you very much
HTML:
<button id="back-button">Go Back</button>
jQuery:
$('#back-button').click(function(){
window.history.back();//go back one page
});
Other possibilities:
window.location.history.go(-1);//go back one page
window.history.back();//go back one page
window.location.href = 'http://www.google.com'; //go to google.com
It's about as clear as mud, but I think he is either after this:
('#back-button').click(function(){
location.href = "/urlofyourhomepage/";
});
Or this:
('#back-button').click(function(){
window.history.back()
});
With a button being on the page with an ID of back-button.
Go Back
I don't (or at least I hope not) think that he wanted to intercept the back button functionality of the browser.
Currently I have 2 pages based on the following URL MyNewApp/purchase and MyNewApp/confirm. On the 2nd page that is /confirm I added a back button with the following
HTML
<button type="submit" class="btn" id="back">
Go Back
</button>
JS
$('button[id="back"]').click(function() {
this.form.action="backToPurchase";
this.form.method="GET";
});
After pressing the back button everything works fine except the URL changed to /MyNewApp/backToPurchase?_method=. How can I set the URL to /MyNewApp/purchase after pressing the back button ?
You Can't just change the URL as you wish.
Think about it, if you could change the URL like that it would be a big security problem.
BUT try to use POST instead, or just send the user to a new page so the URL will change, You have lots of options to solve it, just think.
This is technically the answer to your question, though you might want to think about a better way to do what you want.
window.history.pushState(null, null, “/new-url”);
I would recommend a better option, instead of submitting a form just for redirection, use the following:
$('#back').click(function() {// <-- selecting by id is much faster than selecting by attribute "id"
location.href = '/backToPurchase'; // or '/purchase';
// OR you can do the following :
history.back(); //this will performs as you clicked the back btn from the browser
});
I've got a jquery-ui button. When clicked, I want to move the browser to a url within my domain:
<button onclick='foo'>Go</button>
function foo() {
window.location('/otherpage');
}
is that the right way to do it, and address it relatively? Is there a better way to do this?
Thanks
$('#button-id').click(function() { window.location.pathname = '/otherpage'; });
What do you mean by relatively? To the current page or to the current host? There are a few options you are able to use.
It should be window.location = '/otherpage'; Other than that I think it's fine.