tags26
12-29-2008, 08:36 PM
I am currently opening a URL within a page using XmlHTTP. The page imports, but none of the javascript on that page header is working. I tried just hardcoding the javascript on the main page, but it requires form fields that haven't yet been imported using the tag and i get an error.
Is there a way to also import the headers of the page I am calling?
Test3.cfm has a cfform that creates unique javascript on the header of that page. When i open the URL via XMLHTTP that javascript doesn't carry over.
ajaxCompare.js
*****************************************
/* Ultimater's edited version of:
http://jibbering.com/2002/4/httprequest.html
to serve IE7 with XMLHttpRequest instead of ActiveX */
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
if (!xmlhttp){
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
}
@end @*/
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
/* Ultimater's edited version of:
http://javascript.internet.com/ajax/ajax-navigation.html */
var please_wait = "Please wait...";
function close_url(targetId) {
var e=document.getElementById(targetId);if(!e)return false;
e.innerHTML='';
}
function open_url(url, targetId) {
if(!xmlhttp)return false;
var e=document.getElementById(targetId);if(!e)return false;
if(please_wait)e.innerHTML = please_wait;
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = function() { response(url, e); }
try{
xmlhttp.send(null);
}catch(l){
while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
e.appendChild(document.createTextNode("request failed"));
}
}
function response(url, e) {
if(xmlhttp.readyState != 4)return;
var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following error code: " + xmlhttp.status+" "+xmlhttp.statusText;
var d=document.createElement("div");
d.innerHTML=tmp;
setTimeout(function(){
while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
e.appendChild(d);
},10)
}
*********************************************************************
test.cfm
*********************************************************************
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="ajaxCompare.js"></script>
</head>
<body>
<table>
<tr>
<td valign=top width=150>
<H5>My Navagation links</H5>
<a href="javascript:void(0)" onclick="open_url('test2.cfm','my_site_content');">Open URL</a><br>
</td>
<td valign=top>
<div id="my_site_content">
</div>
</td>
</tr>
</table>
</body>
</html>
******************************************************************************
test3.cfm
*****************************************************************************
<cfform name="myform77">
<cfinput id="pickers4" name="pickmany" type="hidden" value="Apples">
<cfinput id="pickers5" name="pickmany" type="hidden" value="Oranges">
<cfinput id="pickers6" name="pickmany" type="hidden" value="Mangoes">
<cfinput type="hidden" name="pickmany-selected" bind="{pickmany@click}"><br />
</cfform>
Is there a way to also import the headers of the page I am calling?
Test3.cfm has a cfform that creates unique javascript on the header of that page. When i open the URL via XMLHTTP that javascript doesn't carry over.
ajaxCompare.js
*****************************************
/* Ultimater's edited version of:
http://jibbering.com/2002/4/httprequest.html
to serve IE7 with XMLHttpRequest instead of ActiveX */
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
if (!xmlhttp){
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
}
@end @*/
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
/* Ultimater's edited version of:
http://javascript.internet.com/ajax/ajax-navigation.html */
var please_wait = "Please wait...";
function close_url(targetId) {
var e=document.getElementById(targetId);if(!e)return false;
e.innerHTML='';
}
function open_url(url, targetId) {
if(!xmlhttp)return false;
var e=document.getElementById(targetId);if(!e)return false;
if(please_wait)e.innerHTML = please_wait;
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = function() { response(url, e); }
try{
xmlhttp.send(null);
}catch(l){
while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
e.appendChild(document.createTextNode("request failed"));
}
}
function response(url, e) {
if(xmlhttp.readyState != 4)return;
var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following error code: " + xmlhttp.status+" "+xmlhttp.statusText;
var d=document.createElement("div");
d.innerHTML=tmp;
setTimeout(function(){
while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
e.appendChild(d);
},10)
}
*********************************************************************
test.cfm
*********************************************************************
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="ajaxCompare.js"></script>
</head>
<body>
<table>
<tr>
<td valign=top width=150>
<H5>My Navagation links</H5>
<a href="javascript:void(0)" onclick="open_url('test2.cfm','my_site_content');">Open URL</a><br>
</td>
<td valign=top>
<div id="my_site_content">
</div>
</td>
</tr>
</table>
</body>
</html>
******************************************************************************
test3.cfm
*****************************************************************************
<cfform name="myform77">
<cfinput id="pickers4" name="pickmany" type="hidden" value="Apples">
<cfinput id="pickers5" name="pickmany" type="hidden" value="Oranges">
<cfinput id="pickers6" name="pickmany" type="hidden" value="Mangoes">
<cfinput type="hidden" name="pickmany-selected" bind="{pickmany@click}"><br />
</cfform>