page navigation in html - php

Hi i am tryng to implement a web application and i was wondering if html offers any page navigation techniques.
My query is Am going like this in my current page navigation,
Page A --> Page B --> Page C --> Page B
if i press back from this Page B position it will go to Page C, I dont want that to happen, instead, i want it to go to Page A.
The reason is that consider
Page A as login page
Page B as home page with some options, when clicked on any one it will go to Page C
Page C corresponding clicked function, say text boxes where i can input name, address etc, and when i fill and click on submit, it will go to page B.
Now if i press on back button from this Page B, i will be navigated to Page C. I dont want this to happen, i just want to stay in that page in this case.
but if the scenario was like this
A->B->C->D->C..
then on pressing back from last C i need to go to B, and if i press back from B, either stay on that page or prompt me to logout.
Hope my question is clear please dont down vote this, i want to learn, only these forums are there to help me
Please help

The browser-back-button belong to the user.
Its a "go back in history"-button.
so ... imo dont touch it.
provide a useful navigation so that user dont even think about using the back-button =)

There are two ways to do this as far as i am aware.
Personaly i would use JS to create a simple logon page, that opens a page containing an iframe, which is linked to your site. If the user hits back, it will take them to the logon page, as the site is contained within an iframe.
The other way is to change the propertys of the back button, rather than removing it with JS. I think this can be done with.history, but i have never used personaly so i dont know.
Hope this helps :)

Related

Show image on button pressed in another page php

I would like to show certain image on a page which is open in a tab, only when the other page press a button. I know I can post on the other page, but is it going to be live? Because I am not gonna be refreshing the page at all. My whole plan is to press a button on one page and show live result on an another page without refreshing it. How can I make it possible? I just need the basic idea behind it. Sorry if I made it sound complicated.
Thanks

Show different content in sidebar based on user behaviour

I'm planning a site and I was thinking would it be possible to show alternate content in the sidebar based on the behaviour of the visitor? Say the user has clicked on link X on page A and I want the alternate content in the sidebar to be shown on page B, if they clicked on the link. Also, if the visitor fills out a form, would it be possible to associate the tracking cookie information with the submitted form to see what pages the visitor viewed? Would this be easier to implement in a particular cms?
I would appreciate it if someone could at least point me into the right direction. Thanks in advance!
Yes anything is possible & no need for cookies (unless you want to keep a persistent track of the user)
Have a relationship column next to the content in your db, when creating the content assign this value much like a category or tag ect.
Then when user clicks on link A as the page loads store its relationship in the session, then when link B is clicked load content related to the previous set session value.

Make hierarchical back button in either javascript or php

I'm creating a mobile theme for my website and I decided it'd be nice to make a back button for people that shows up in the header of the site next to the title. Now I figured out how to make a back button in both javascript or php, and this works just fine in taking the user back to the last page visited.
Javascript:
<input type="button" value="Go Back From Whence You Came!" onclick="history.back(-1)" />
PHP:
<?php
$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
echo "<a href='$url'>back</a>";
?>
Now the issue is I don't want people to go back to the last page they visited but rather go up the hierarchy of pages back up to the home page eventually.
Right now this is how it works:
I go to page A
Then I go to page B, and click to go to page C.
When I click the back button on page C, I get to page B.
When I click the back button on page B, I get to page C.
How I want it to work:
I go to page A
Then I go to page B, and click to go to page C.
When I click the back button on page C, I get to page B.
Then when I click the back button on page B, I get back to page A.
So I need it to work more like the normal back button on the browser and not just take you back to the last page you were on because that leads to an infinite loop which I'm sure will make people upset.
Also it's probably worth noting that I'm working on a huge site with tons of content built off of Drupal 6 on 1 page.tpl.php file. So I can't simply say if on page B go to page A but it needs to be something dynamic that works no matter where I plug it.
Thank you so much for your help!
If you still want to add this button (which might screw up the forward button for your browser) you can probably do it with a php session object or whatever it is called, I dunno php that well but here is the logic which I think will work
Each time you go to a page, save URl in this persistence variable/array, output the last entered URL as the url of the button then add current URL to this array. when you click the button you need to delete the URL in the link from the array and everything after it.
a-b-c-d
if you are on page d and press back, you need to remove c and d and output the link as b
OR
if you are on d and press back you need to remove d and output b as URL
then when are at the end meaning you are on page a, the button will disappear.
his seems like a lot of work to put in something that exists in every browser

Back button on pages with tabs

I'm doing a system where the pages are displayed by tabs (easytabs Plugin http://os.alfajango.com/easytabs/#tabs1-js)
At one point in the process it performs a query in the database, where we
see all the details of each item that appears. I'd like to go into the details of the item, click back to the (on broswer or a button) the page to return to the list displayed by the SQL query, just as with any single page, but currently it only displays a blank page.
I wonder how can I do to implement this solution using the layout tabs.
Thank you.
There are various ways to maintain UI state. One of them is using a "url hash". For example, you click tab 2, change the url hash to:
mypage.php#tab=2
Then if someone presses BACK and goes FORWARD, you use JavaScript to look at the URL has and determine that the user had previously pressed tab 2, so you run your own bit of code that triggers the same event.
I'm unfamiliar with "easytabs" so I'm sorry I can't help with the specific implementation details, but that's the gist of the technique.

let jquery know which was the last visited php page?

this is a little bit tricky.
usually when someone clicks on a link that requires him to register, this person will be redirected to the registration page and then back to the last visited page. this is possible cause the link sent a GET key through the url to the registration.php which uses the key to go back to last visited page.
but i intend to use jquery ajax for registration. basically ive got 3 different php pages. all of them include the same header.php. and in header.php ive got a registration button which i have id tagged. when this button is clicked ( $(#registration_button).click()... ) jquery will show a box (a div that was hidden in the center of the browser) with registration information. then he will register and i will redirect him to the last visited page, that is to say the current one he sees. i have to refresh the php-page to be able to show all links that a registered user can see, thats why i have to use window.location.href.
now to the question. how do i let jquery know which page is the current one he is visiting? ive got 3 php-pages.
if there is something you dont understand, please free to ask.
or if you got suggestions of other solutions, let me know. but i really want to display the registration box right away without redirecting him to another page.
You can set cookies initially in php and then update/read them via js.
You could assign the page to a session and do it that way.
$_SESSION["page_visited"] = "x.php";
Make sure to use session_start on the pages using sessions. Then just redirect to the relevant page.
header('Location: http://www.example.com/'$_SESSION["page_visited"]);
I did a similar thing not two weeks ago, correct me if I'm wrong, but if you want the registration to direct to the page the user was on, after the user has been registered in the ajax just add:
window.location.href=window.location.href;
That way the after the registration is done, it just reloads where the member was with the environment of a logged in user. This method worked great for me.

Categories