Jump to content

Archived

This topic is now archived and is closed to further replies.

OriginalSunny

How to open links to pages correctly

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??

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

×

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.