Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[HTML] Open link in same window

Elite Diviner
Joined
Aug 15, 2008
Messages
489
Reaction score
43
Hello.

How can I open a link in a same window?

I am having a website with a navigation, with Home and etc. I would like it to open a new link under the navigation when one of the items are being pressed.

For example if I click on Home, it opens a new link under it, with news or anything.

How to do that?

EDIT: The thing I mean is like this:
Wokki - [HTML] Open link in same window - RaGEZONE Forums

I want it to show the item at the red box when I click on the "Home" button.
 
Last edited:
Elite Diviner
Joined
Aug 15, 2008
Messages
489
Reaction score
43
Code:
<a href="#" target="_self">123</a>

I guess I explained it wrong or something, but what I want is not that.

Like when I click on the link, it wont move from the page to another one, instead it open the page to the page I were on.

I don't know if you understand what I mean, but thats it somehow.
 
Elite Diviner
Joined
Aug 15, 2008
Messages
489
Reaction score
43
Like a php ?act=pagename function?

So when you click on a link the page appears in the main box on your webpage?

Thats exactly what I mean!
Any website explaining how to use this, or can you explain it to me?
 
Elite Diviner
Joined
Aug 15, 2008
Messages
489
Reaction score
43
I'm pretty sure that can be done with AJAX or even just Iframes.

Well I wasn't sure in which coding language to do, so I just decided to name the title as
HTML:
, anyway, can someone explain me how it works?

EDIT: Can it be done like on click it opens a home.php to my <div "item">here</div>
 
Last edited:
Master Summoner
Joined
Oct 9, 2008
Messages
572
Reaction score
14
You could also use Ajax to change the content instead of loading a new page. But the downside is just that you will have a little difficulty having a specific URL link to the content if you just click and load new content without changing the URL. But it's possible.
 
Joined
Jul 26, 2006
Messages
3,634
Reaction score
1,007
Don't confuse the fella, guys.

-

Just use iFrames:
Code:
<iframe name="main" src="home.html">Your browser doesn't support iFrames! Get firefox n00b.</iframe>

That will create an iFrame named "main" (and if it -in some way- doesn't work it'll show that text) with default page "home.html" shown.

Code:
<a href="info.html" target="main">Info</a>

That will show the page "info.html" in the iFrame -without- refreshing the entire page! It just changes the iFrame.
 
Master Summoner
Joined
Oct 9, 2008
Messages
572
Reaction score
14
I'm not sure if I were misunderstood, but this is somewhat what I ment:
Code:
<!DOCTYPE html>
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <script type="text/javascript" src="./js/jquery.js"></script>
 </head>
 <body>
  <div id="sitecontainer">

   <div id="banner"></div>

   <div id="leftmenu">
    <a href="#" class="Index">Index</a><br />
    <a href="#" class="Downloads">Downloads</a>
   </div>

   <div id="content"></div>
      <script type="text/javascript">
      //jQuery
       $(document).ready(function() {

          $('.Index').click(function() {
            $('#content').load('./pages/index.php');
          });
          $('.Downloads').click(function() {
            $('#content').load('./pages/dl.php');
          });

       });
    </script>
   </div>
 </body>
</html>

This loads a php document into the "content" div and that was what I ment to be a little hard to get a specific url for the file being loaded upon load.

But the thing with iFrame seems a lot quicker and more noob friendly than this.
 
Custom Title Activated
Member
Joined
Dec 10, 2007
Messages
2,194
Reaction score
263
You could use this code I just made, if I get what you're saying..

This PHP code will allow you to put content on the page, without having to create a new page.

PHP:
<?php
$page = $_GET['src'];
if($page) {
  $link = "inc/{$page}.php";
  if(file_exists($link)) {
    include($link);
  }else{
    echo "Page could not be found.";
  }
}else{
  include("inc/home.php");
}
?>

Simply put your content in inc/, and make sure it's a php file. Then put the code above in your index.php file, where you want the content. Last thing you have to do, is figure out the url. The url for a page would be index.php?src=(PAGE NAME HERE). Also, if you leave the url as just index.php, it'll go to your homepage content.
 
Joined
Jul 26, 2006
Messages
3,634
Reaction score
1,007
You could use this code I just made, if I get what you're saying..

This PHP code will allow you to put content on the page, without having to create a new page.

PHP:
<?php
$page = $_GET['src'];
if($page) {
  $link = "inc/{$page}.php";
  if(file_exists($link)) {
    include($link);
  }else{
    echo "Page could not be found.";
  }
}else{
  include("inc/home.php");
}
?>

Simply put your content in inc/, and make sure it's a php file. Then put the code above in your index.php file, where you want the content. Last thing you have to do, is figure out the url. The url for a page would be index.php?src=(PAGE NAME HERE). Also, if you leave the url as just index.php, it'll go to your homepage content.

Not 100% sure that's what he wants... If, for example, you'd have a link to "?src=info" and click that, the page would still refresh as if you clicked a normal link to "inc/info.php". It just looks different.

This guy wants a simple solution for his webpage, I say iFrames is the way he should go.
 
Initiate Mage
Joined
Oct 25, 2010
Messages
2
Reaction score
0
I'm not sure if I were misunderstood, but this is somewhat what I ment:
Code:
<!DOCTYPE html>
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <script type="text/javascript" src="./js/jquery.js"></script>
 </head>
 <body>
  <div id="sitecontainer">

   <div id="banner"></div>

   <div id="leftmenu">
    <a href="#" class="Index">Index</a><br />
    <a href="#" class="Downloads">Downloads</a>
   </div>

   <div id="content"></div>
      <script type="text/javascript">
      //jQuery
       $(document).ready(function() {

          $('.Index').click(function() {
            $('#content').load('./pages/index.php');
          });
          $('.Downloads').click(function() {
            $('#content').load('./pages/dl.php');
          });

       });
    </script>
   </div>
 </body>
</html>

This loads a php document into the "content" div and that was what I ment to be a little hard to get a specific url for the file being loaded upon load.

But the thing with iFrame seems a lot quicker and more noob friendly than this.

really needing some help on this!! i wanna do the very same thing! but i have a drop down naviagation menu and want every link thats relivent to the site to load in a container so then there is 1 main page and setup that never changes only the cotainer that will hold the new pages that are from the links.
now if this is the correct code then i just need some help working it out!
and i dont wanna use iframes cause im told and read that it effects the seo of the site :(
really need some help been a long time searching about and now decided that i cant do it alone and need some help :D
 
Initiate Mage
Joined
Oct 25, 2010
Messages
2
Reaction score
0
bad bump should of have quoted this and made a new thread. well what ever

ah was that for me? if so as u can tell very new to the site!! u recomend that i start a new thead yh? was hoping to get help from any who viewed this and gained from it! :( ahh k well advice on moving forward would be sweet thanks!
 
Back
Top