473,228 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,228 software developers and data experts.

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

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

Jun 6 '07 #1
5 38960
On 6 Jun, 17:36, chakradhari.ash...@gmail.com wrote:
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.

Jun 6 '07 #2
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.
Jun 6 '07 #3
ch****************@gmail.com said the following on 6/6/2007 12:36 PM:
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>?
Yes, I know how.
I googled around and followed some links pointing me that it is
possible to use javascript combined with CSS for doing this?
Yes, it is possible to do with javascript.
Any ideas?
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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 6 '07 #4
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;
}

On Jun 6, 5:00 pm, Moyzes <moy...@gmail.comwrote:
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.

Jun 7 '07 #5
On Jun 6, 8:52 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
chakradhari.ash...@gmail.com said the following on 6/6/2007 12:36 PM:
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>?

Yes, I know how.
I googled around and followed some links pointing me that it is
possible to use javascript combined with CSS for doing this?

Yes, it is possible to do with javascript.
Any ideas?

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.

Jun 7 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David | last post by:
Do you consider <div id="header">/<div id="footer"> presentational, just like <div id="leftmenu"> or similar?
2
by: Shaun | last post by:
Hello! I have a quick question regarding CSS and having it applied to all elements. I am trying to eliminate the gap between a paragraph and a list that usually occurs in html and I've found...
16
by: rik | last post by:
I was flicking through a PHP book (one of the teach in 24 hour ones) and I came across something I had never seen before in PHP. It was a method of printing out without using the print method, it...
3
by: Jim in Arizona | last post by:
Most of the asp.net learning I've done has been from books that were written during the 1.0 framework. I didn't have a copy of visual studio when I started reading them then I got a hold of VS 2005...
5
by: Alex Maghen | last post by:
The editor says that when using <a name="xyz" />, the "name" element is "obsolete" but it doesn't suggest a replacement. What's wrong with <a name="xyz" /> to set a page anchor?
4
by: sam | last post by:
Hi all, When I use the HTML tidy tool in Firefox I see the following warning which I want to get rid of . I cleared all the errors and warnings it showed except for this one. I am not able to...
3
by: rkhurana | last post by:
Hi I am writing a JSF application that uses some third party charts. While I can see the chart but the javascript that is supposed to calla function to update chart periodically has a problem. It...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.