Arringar1
Arringar1

Reputation: 415

How to use DIV or IFRAME to display a page within a page

I'd like to display a welcome page upon sign in to my company website. Currently this page has some account summary data/details. I'd like to be able to use this same space to display billing info but I don't want the user to leave the page they're on.

How can I accomplish this? It is imperative that I am able to put the code for this within the page that is already loaded.

Upvotes: 0

Views: 16685

Answers (4)

btlr.com
btlr.com

Reputation: 139

Here's the code to load content from other URL dynamically (AJAX). You do not need jQuery just for this simple task

function loadXMLDoc(aURL){
    var xmlhttp;
    if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else{// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function(){
        if (xmlhttp.readyState==4 && xmlhttp.status==200){
             var div = document.getElementById ("your_div_ID_goes_here");
             div.innerHTML = xmlhttp.responseText; // this is the content you received,
        }
    }
    xmlhttp.open("GET",aURL,true);
    xmlhttp.send();

}

Upvotes: 0

btlr.com
btlr.com

Reputation: 139

var div = document.getElementById ("your_div_ID_goes_here");
div.innerHTML = "<b>Any html content. <br> Enjoy!</b>";

this will help you :)

Upvotes: 1

Ty Strong
Ty Strong

Reputation: 227

You can use an iframe like this:

<iframe src="http://www.w3schools.com"></iframe>

The src="blahblah" can be switched to any website or page you would like.

Although an iframe doesn't sound like something that works for what you need. It sounds like you need to add content depending on whether it is their first time visiting the page. You could use php or javascript to grab the cookies and do this.

Upvotes: 3

Bala
Bala

Reputation: 510

You have to make ajax call to page to fetch the data and append the response to a div where you want to display.

use jquery $.ajax

Upvotes: 0

Related Questions