Loading HTML pages inside <div id="x"></div>

  • Thread starter chakradhari.ashish
  • Start date
C

chakradhari.ashish

Does anybody know how can I load an html page inside a <div> </div>
where the content gets update on the onclick even of anchor <a href=>
</a>?

I googled around and followed some links pointing me that it is
possible to use javascript combined with CSS for doing this? Any
ideas?

Chakra
 
P

petethebloke

Does anybody know how can I load an html page inside a <div> </div>
where the content gets update on the onclick even of anchor <a href=>
</a>?

I googled around and followed some links pointing me that it is
possible to use javascript combined with CSS for doing this? Any
ideas?

Chakra

You want to put a complete page inside a div element?
Normally you'd use the innerHTML method to change text inside a div.
 
M

Moyzes

In this case, use xmlhttprequest. Give to the div an ID first, then...

var req = new XMLHttpRequest();
req.open("GET", "page.html", false);
req.send(null);

var page = req.responseText;

document.getElementById("your div").innerHTML = page.

It's done.
 
C

chakradhari.ashish

Dear Moyzes,

Thanks a lot! It worked.

my link looks like:

<li><a href="" onclick="loadNewPage('indexp.html'); return false;"
id="current"></a></li>

function loadNewPage(temp) {
var req = new XMLHttpRequest();
req.open("GET", temp, false);
req.send(null);
var page = req.responseText;
document.getElementById("rcol").innerHTML = page;
}
 
C

chakradhari.ashish

(e-mail address removed) said the following on 6/6/2007 12:36 PM:


Yes, I know how.


Yes, it is possible to do with javascript.


I have lots of ideas, some of which are not fit to be posted to a family
oriented group.

Try reading the FAQ. The URL is in my signature.

Thanks! Sorry for the generic question. But before posting it, I did
try the ways known to my limited knowledge of this field, and when I
could not do it, I thought of asking the requesting the experts!

In any case, your signature was useful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top