Jump to content

How to open links to pages correctly


OriginalSunny

Recommended Posts

Hi,
When using my webpage everytime a link is clicked on, a totally new page is opened. I want it so that the navigation bar is always displayed on the side of the page no matter what the user is doing. Currently i am using the following code for the navigation bar:

[i]<a href="contact.php">Contact Us</a><br><br>
<a href="accessories.php">Accessories</a><br><br>[/i]

As you can see the menu page is in html and some of the other pages are also in html or in php. Currently whenever a page is clicked on the navigation bar dissappears and a new page is created. How do i do it so that the navigation bar always stays on the side??
Link to comment
Share on other sites

I hope you don't mean a new browser window for every link!

The simplest solution would be to use the include() function to add your menu to every page. Then changing your menu would automatically update all your site's pages.
Link to comment
Share on other sites

I dont mean a new browser for every link. I have tried the include() function and it does work, however depending on where i put it, the menu bar page comes up either above or below the other page. The way i want it, the menu bar should come up on the left of the other page which is opened (like on this phpfreaks website).
Thanks.
Link to comment
Share on other sites

Save this (and nothing more) as menu.php
[code]<a href="contact.php">Contact Us</a><br><br>
<a href="accessories.php">Accessories</a><br><br>[/code]

Then when you want the menu to show on any page, place this exactly where you want your menu to appear:

[code]
... blah blah blah page stuff

<?php
// add my menu
include("menu.php");
?>

... blah blah blah more page stuff
[/code]
Link to comment
Share on other sites

Why don’t you use frames?

You could create a navigation frame with the links on and when those links are accessed the new page content is displayed in the main frame of the page. It would be like having your page split into two.

The code you would use to make the links appear in the new frame would be

[code]
<a href="contact.php" target="MAIN_FRAME">Contact Us</a><br><br>
<a href="accessories.php" target="MAIN_FRAME">>Accessories</a><br><br>
[/code]

Obviously you would substitute the MAIN_FRAME target to whatever you call your frame!

I know it doesn’t use php but it’s by far the easiest way to do what you’re doing!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.