473,378 Members | 1,467 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,378 software developers and data experts.

Import html page in another html page using AJAX

I am having a site in which dynamically header part is changing as in each and every page there is a script called which checks the referring url and according to that url script invoke a header.html which is used in AJAX and called as .txt file using XMLHttp.open .

Complete HTML page is imported but if there is any javascript code exists in the header.txt. Javascript code does not get executed.

Can any body help me out how to use javascript codeusing AJAX function used as follows.

Expand|Select|Wrap|Line Numbers
  1. function loadXMLDoc(url)
  2. {
  3.     //alert("URL  "+url);
  4.     head_url = url + "header.txt";
  5.     button_url = url + "buttons01.txt";
  6.     foot_url = url + "footer.txt";
  7.     fill_url = url + "fill.gif";
  8.     if (window.XMLHttpRequest)
  9.       {// code for IE7+, Firefox, Chrome, Opera, Safari
  10.           xmlhttp=new XMLHttpRequest();
  11.       }
  12.     else
  13.       {// code for IE6, IE5
  14.           xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  15.       }
  16.     xmlhttp.open("GET",head_url,false);
  17.     xmlhttp.send(null);
  18.     document.getElementById('header').innerHTML = xmlhttp.responseText;
  19.     //alert("head url "+head_url);
  20.     xmlhttp.open("GET",foot_url,false);
  21.     xmlhttp.send(null);
  22.     document.getElementById('footer').innerHTML = xmlhttp.responseText;
  23.     document.getElementById('but').style.backgroundImage = "url(" + fill_url + ")";
  24. }
Apr 8 '10 #1
1 2364
gits
5,390 Expert Mod 4TB
'ajaxloaded' JavaScript-code needs to be evaled explicitly ... since it is not a normal page-load ... you have to tell the browser that it should interpret the loaded text as JavaScript-directives
Apr 15 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
2
by: pamelafluente | last post by:
Hi dears, I have a plain HTML page. I want to render it a little interactive. I was thinking to add to it 1 script and events to the elements I want to make interactive. Then, I need to...
7
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it...
13
by: Marvin Zhang | last post by:
Hi, I'm not familiar with web programming, but I have a problem here. I have a page. When a user click one button on it, I will use AJAX to request a PHP script which will do a bunch of tasks,...
1
by: mmalloc | last post by:
Hi, I need to create some javascript function when clicking a link to get some html code from the server (a php page) and replace the link on that page with the html. By posting here I hope i...
13
by: mowsen | last post by:
Hello Group, i'm using a little "ajax" loader script to dynamically load files into different "div" tags on my main site. the code for this part looks like: function loader() { var args =...
10
by: paulie | last post by:
Hi, I have been experiencing an issue when trying to use AJAX to reload a DIV area using a timer of 2000ms, which contains a html page with another DIV and javascript. Scenario -------------...
4
scubak1w1
by: scubak1w1 | last post by:
Hello, Is there a 'trick'/technique to see what the code on a page looks like on the client side after AJAX adjusts part of it? (for the example I had in mind, as the user selects items from...
4
by: Nicolas R | last post by:
Hi all, Im trying to figure out how to display a 'loading' message when scripts are being executed, ie when the page is still not ready for interaction. This is for a web app which relies on...
2
by: Max | last post by:
I recently moved to ASPnet Ext 3.5 What I can't get with Ajax and History browser managemet is this: User fills some fields (dropdown and textbox) on page 1 (all are in an update panel) User...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.