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

Execute javascript from inside loaded httprequest files

Hi: I've ben looking for a long time for an answer to mi problem. The thing is that I'm uin httprequest object to load files inside div tags. It works ok. My problem is that any javascript code defined inside my loaded fields simply can't bedetected, can0t be executed. I really need this to work because the I work with javascript code to measure he visits to this loaded files. And this code is defined on every page that is called by the httprequest
Jun 4 '07 #1
3 2407
acoder
16,027 Expert Mod 8TB
Hi marcofabian, welcome to TSDN!

Post some code (in code tags) so we have an idea of what the problem might be.
Jun 4 '07 #2
Hi:
I'm using httprequest to load the content of html files into div tags of a main page. It works ok, but the javascript defined inside the html files is simply not detected. In the followin example, the js function InsideTest is not detected, never gets executed. This is my code:

JS External File with httprequest :
function cargarHttpRequest(url, id_contenedor){
//if (id_contenedor != 'topVariosInteriores' && id_contenedor != 'destacadosPrincipal') document.getElementById(id_contenedor).innerHTML=' CARGANDO...'
var pagina_requerida = false
if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
pagina_requerida = new XMLHttpRequest()
} else if (window.ActiveXObject){ // pero si es IE
try {
pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){ // en caso que sea una versión antigua
try{
pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
pagina_requerida.onreadystatechange=function(){ // función de respuesta
mostrarArchivoHttpRequest(pagina_requerida, id_contenedor)

}
pagina_requerida.open('GET', url + '?' + aleatorio , true) // asignamos los métodos open y send

pagina_requerida.send(null)
}
function mostrarArchivoHttpRequest(pagina_requerida, id_contenedor){
if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(id_contenedor).innerHTML=u nescape(pagina_requerida.responseText)

}


Main Calling Page:

<body "onload=Insidetest()">
<div id="cajasChat">
</div>
<script language="javascript">
cargarHttpRequest('/includes/autonoticias/portada/portada_videoChat_1.htm', 'cajasChat')
</script></body>


Html Small Content file: portada_videoChat_1.htm)
<div>Text to fill another page</div>
<script language="javascript">
function Insidetest(){
alert('hello world')
}
</script>


thanks in advanced
Jun 5 '07 #3
acoder
16,027 Expert Mod 8TB
Threads merged. Please post information relating to the same problem in the same thread.
Jun 5 '07 #4

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

Similar topics

4
by: annoyingmouse2002 | last post by:
Hi there, sorry if this a long post but I'm really just starting out. I've been using MSXML to parse an OWL but would like to use a different solution. Basically it reads the OWL (Based on XML)...
1
by: sams | last post by:
How can I assign a return value of a CGI to a JavaScript variable? Or what is the correct way? <script> var myData = eval(http://somewhere/cgi-bin/data.cgi"); </script> TIA Sam
2
by: JF | last post by:
Hi, can somebody give me a minimal example of how to read xml file into mozilla AND run some Javascript funcion? Mozilla can read xml files directly and css files can be included as well,...
9
by: Robby Bankston | last post by:
I'm working on some code and am running into brick walls. I'm trying to write out Javascript with Javascript and I've read the clj Meta FAQ and didn't see the answer, read many similar posts (with...
3
by: dmckeon | last post by:
I have a Javascript that is building an XML string and then invokes a JSP. I need to pass the XML string from the Javascript to the JSP. What's the best way to do that? I am new to this...
2
by: quindo | last post by:
Hello, I've searched the internet but couldn't find an answer so I'm hoping someone here can help me. A webpage recieves XML from the server using xmlhttp. What I want to do is search in this...
6
by: Venkatesh | last post by:
Hello All, I have couple of doubts regarding the concept of on-demand javascript loading using javascript code. I could see on the net different techniques for achieving this - techniques like:...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.