how to call previous page without ajax - javascript

Hi all i am developing an application for blackberr5 which does not support ajax. By using window.location.href = "MainMenu.html"; I am navigating from one html into another. Now in MainMenu.html file I have header as :
<div data-role="header" align="center">
Back
<h1>Test.html</h1>
Menu
</div>
But when I click on back it is not going to previous page. And if I use $.mobile.changePage('MainMenu.html'); then back button works fine. Then for blackberry5 how to handle back button. Any suggestion will be appreciated.

Have you tried using history.back()
You can find some useful info about back buttons in jQuery mobile here: http://jquerymobile.com/test/docs/toolbars/docs-headers.html

try one of these two
history.back() or history.go(-1)
Hope it will work

Related

Javascript back button not working properly -scrolling to the bottom of the page, instead of previous scroll location

I'm using the following code on a wordpress website and it is only present on the post pages:
<button onclick="history.back()">Back</button>
What I would like the code to do is bring the user directly back to the spot where they left off on the previous page and for the most part the code is working fine.
Problem: After clicking forward and then clicking back a few times - the back button will continue to bring you back button, however not to the same scroll spot - it actually brings you back to the bottom of the webpage and will keep doing this every time until you leave the website and then return.
Any help with this problem will be greatly appreciated.
Here is my website address - if that helps >> http://rumpleskilton.com/djs-bands-singers/
(to see the problem - select one of the listings and then click the back button, which is just above the page header. It could take several times to see the problem. Just click a few of the listings.)
have you try this way ?
<button onclick="window.history.back()">Back</button>
i hope it's help you.
I believe you are using Chrome. Chrome is known to demonstrate such behaviour. Try with Firefox and MS Edge and see if you get the same result (I trust you won't).
In any case, the safest method is to use the page URL to navigate to, instead of back(). Alternatively, you could save the last page name in the url (?lastpage=index or whatever) and change your back() function to grab that page name and navigate there.
Trusting the browser behaviour is not your friend in this situation.

Making a div appear on button click (PHP)

I am a first poster here so please excuse my noob-like behavior.
I have a button on my website that when pressed should disappear, and a form should be echoed out in its place without a page refresh.
I have easily achieved this with JavaScript / AJAX, but if JavaScript is disabled, I still want the button to do it's task.
My question is: Can I do this only using PHP, WITHOUT a page refresh?
Cannot comment or I would have but the answer would be no. PHP is server side so the only way for it to update a view is to reload to a new page. Also, I would think it is very unlikely to run into a situation where JS is disabled these days.
Not in a way I think you'd want to do it, but you could use an iframe that contains the button. The button would be a link or form submit and the navigation would happen inside the iframe to your form. This way, only the iframe is refreshed, but the full page remains unchanged.
You can only aciehcve this using ajax. You can force your users to enable
javascript noscript tags
<noscript>
<p>This page requires a JavaScript-enabled browser.</p>
</noscript>

JS not loading correctly on first pageload

When I load the page for the first time, I have a menu, element in the menu might have "current_page" class which I add via PHP if the current page is the menu element. Now the problem is when I enter the page for the first time or refresh it with ctrl+f5, which is the same, the slider that is suppose to go under the "current_page" class is slightly off. Different in Firefox and Chrome (see pictures below), but after I refresh the page with normal f5 or click on some links, so the page reloads, everything goes bask to the right and works until I hardreload the page again. I tried to make a JS fiddle but there it works every time. So I will post the link online, so you can see it there and tell me if you also have the problem.
<nav>
<div class="menu_slider"></div> <div class="navigation current_page">Home</div>
<div class="navigation">About Us</div>
<div class="navigation">Blog</div>
<div class="navigation">Magazine</div>
<div class="navigation">Contact me</div>
</nav>
I have to paste some code or it won't let me post the comment.
Thank you for any help possible.
Use jquery or put your code into a window.onload method. That will most probable help it. Please let me know.

jQuery AJAX back button after changing html

I know there are many questions about jQuery + Back button issues, but it seems that they're trying to maintain history features when clicking the browser back/forward buttons.
My question is that when clicking the back/forward button, how can I load ajax-affected html page?
For example,
In index.html, dynamically remove all "div" elements from the list using AJAX (jQuery.post()).
Press the browser back(or forward) button to go to newpage.html.
Press the browser forward(or back) button to go to index.html again.
PROBLEM: the html page contains the deleted "div" elements.
How should I load index.html with no "div" elements after step (3)?
I'm currently using jQuery and Django as backend.
Thanks!
Use the jQuery history plugin to encode the application state. See their Demos page for examples of how to do what you want.

solution for popup page as modal

I was using window.showModalDialog() but doesn't work on all browsers.
People recommends me jquery, thickbox and also this contact Example
but the problem is when i submit the page, server will send me another page, and that page will replace my original page!
so actually it doesn't fulfill my requirement.
My requirement is on button click modal page should open and it can redirect to other page on same window without disturbing my original page and when I close My original page get reflections.
So is it possible?
Sounds like you need a simple html target="_blank" in the link to the other page.
http://www.htmlcodetutorial.com/linking/_A_TARGET_95y98y108y97y110y107y.html

Categories