Jump to content

how to load several external Web pages in 1 page


Recommended Posts

Hi,

 

I have written a simple menu on the left side of my web and left a space open in the middle of my web page.

 

Something like this:

-------------------

item a ! !

item b ! !

item c ! !

item d ! !

item e !------------------!

 

I would like now to insert a webpage in the open space according to the choice of the left.

 

Example:

 

item a = man.hrml

item b = womman.html

item c = child.html

item d = pet.html

item e = car.html

 

I have tried to use "IFrames" but this allows me to link only 1 webpage to the main page.

 

Any ideas how to program this.

 

TIA

Link to comment
Share on other sites

well, to add several webpages all you need to do is use frames:

for example:

 

<html>

 

<frameset cols="25%,50%,25%">

 

<frame src="frame_a.htm">

<frame src="frame_b.htm">

<frame src="frame_c.htm">

 

</frameset>

 

</html>

 

this means there will be 3 different web pages in only one page two taking 25% of it and one taking 30% of it, if u dont get it then reply me back

Link to comment
Share on other sites

well, to add several webpages all you need to do is use frames:

for example:

 

<html>

 

<frameset cols="25%,50%,25%">

 

<frame src="frame_a.htm">

<frame src="frame_b.htm">

<frame src="frame_c.htm">

 

</frameset>

 

</html>

 

this means there will be 3 different web pages in only one page two taking 25% of it and one taking 30% of it, if u dont get it then reply me back

 

This is not what I want to do.

 

I want to show only one web page (in a frame) at the time.

 

According to the choice made at the left side menu, another web page with only the essentilal data will be displayed at the same place without the need to load a complete webpage again.

 

Suppose a menuj with the buttons "Home", "Contact Us", "About us", etc...

In a normal situation, each button will load the according webpage "Home.html", "Contact.html", "About.html", etc.

 

I would like to have 1 main webpage with a open space or a frame and load/display the different webpages in the main page according to the choice made.

 

Something like is done with graphics and the command "onmouseover", "onmouseout", etc...

Link to comment
Share on other sites

  • 3 weeks later...

You could use frames but modern websites use ajax instead. It takes a few extra steps but it's well worth it because once you know ajax you can do so much more.

 

First of all, you need to use php to include the menu. Hopefully I didn't have to tell you that but because the rest of this will go way over your head:

<?
     include('menu.php');
?>

 

HTML for Menu.php:

<span class="menuItem" onClick="ajaxPage('item1')">Item1</span>
    <span class="menuItem" onClick="ajaxPage('item2')">Item2</span>
    <span class="menuItem" onClick="ajaxPage('item3')">Item3</span>
    <span class="menuItem" onClick="ajaxPage('item4')">Item4</span>

 

Javascript (on index page, not the menu include):

    //Set Ajax
    if(window.XMLHttpRequest){
    ajaxRequest = new XMLHttpRequest(); //Good browsers
    } else if(window.ActiveXObject){
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); //IE
        } else {
            alert("Your browser broke!");
        }
        
    function ajaxPage(x){
        var page = x+".php";
        var right = document.getElementById("content").style; //Where you want the page information to go.
        ajaxRequest.onreadystatechange = function(){
            if(ajaxRequest.readystate==4){ //4 means the request is complete.
                right.innerHTML = ajaxRequest.responseText; //Gets all printed information from the page. Only includes html.
            }
        }
        ajaxRequest.open("GET", page, true); //Accesses the page (i.e. item1.php)
        ajaxRequest.send(null); //Used for POST method
    }

 

Example script~ item1.php:

<?
     $one = 1;
     $two = 2;
     $sum = $one + $two;
     echo $sum;
?>

The response text will become 3. It will not include any php, only html code.

 

A bit confusing? The w3schools ajax tutorial is superb.

http://w3schools.com/ajax/default.asp

Link to comment
Share on other sites

  • 2 weeks later...

you can do something like this also:

<?php

if(isset($_REQUEST['page'])){

//use your own pages or you may echo dynamic content here as well

if($_REQUEST['page']=="aboutus"}

include("aboutus.html");

}else{

//you may use html here

 

 

echo "<a href=\"index.php?page=aboutus\">Aboutus</a>";}

?>

 

 

if this works or not,reply

 

if(isset($_REQUEST['page'])){
//use your own pages or you may echo dynamic content here as well
if($_REQUEST['page']=="aboutus"}
include("aboutus.html");
}else{
//you may use html here


echo "<a href=\"index.php?page=aboutus\">Aboutus</a>";}

#save this page as index.php or else with ext .php

Link to comment
Share on other sites

you can do something like this also:

<?php

if(isset($_REQUEST['page'])){

//use your own pages or you may echo dynamic content here as well

if($_REQUEST['page']=="aboutus"}

include("aboutus.html");

}else{

//you may use html here

 

 

echo "<a href=\"index.php?page=aboutus\">Aboutus</a>";}

?>

 

 

if this works or not,reply

 

if(isset($_REQUEST['page'])){
//use your own pages or you may echo dynamic content here as well
if($_REQUEST['page']=="aboutus"}
include("aboutus.html");
}else{
//you may use html here


echo "<a href=\"index.php?page=aboutus\">Aboutus</a>";}

#save this page as index.php or else with ext .php

 

Double posting won't get you anywhere. It just makes the page longer and get's you banned. Use the edit tool in the future.

 

 

@JF_sly I went to that page and I don't think iframes will work in your current situation, and It would take a longer time to load as well.

Link to comment
Share on other sites

Hey ,it was just a mistake but Why i will be banned because it not a spam or bad grammer but i am sorry for that.

sorry, I hope this load of smileys makes up for it

:D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D

 

I think this topic is pretty much done now, unless things still aren't working for JF

Link to comment
Share on other sites

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.   Paste as plain text instead

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