473,503 Members | 5,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 38981
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
3995
by: David | last post by:
Do you consider <div id="header">/<div id="footer"> presentational, just like <div id="leftmenu"> or similar?
2
7617
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
1916
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
3475
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
1780
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
3747
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
3788
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
2877
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
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.