...

View Full Version : Loading JS in the same id place..PLZ HELP



nospirit
12-27-2005, 12:25 PM
Dear all
I search all the net about this answer but I could not find any script for it
or if that can be or not ..
we have loaded external js with id ="anyname"
I need to click on button to load another external js in the same place I mean in the same id
please click to see the example :
http://www.creativelink-sy.com/example/test.html

please inform me as soon as possible

thanks in advance

vwphillips
12-27-2005, 12:38 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>

<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/

var JSAdd;
var CSSAdd;

function AddJS(name){
if (getFile(name)==null){ return; }
head=document.getElementsByTagName('HEAD')[0];
// next line removes the previously added External JavaScript
if (JSAdd){ head.removeChild(JSAdd); }
JSAdd=document.createElement('SCRIPT');
JSAdd.type='text/javascript';
JSAdd.src=name;
head.appendChild(JSAdd);
}

function AddCSS(name){
if (getFile(name)==null){ return; }
head=document.getElementsByTagName('HEAD')[0];
// next line removes the previously added StyleSheet
if (CSSAdd){ head.removeChild(CSSAdd); }
CSSAdd=document.createElement('LINK');
CSSAdd.rel='stylesheet';
CSSAdd.type='text/css';
CSSAdd.href=name;
head.appendChild(CSSAdd);
}

function getFile(filename){
oxmlhttp = null;
try {
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/xml");
}
catch(e){
try { oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e){ return null; }
}
if(!oxmlhttp) return null;
try {
oxmlhttp.open("GET",filename,false);
oxmlhttp.send(null);
}
catch(e){ return null; }
return oxmlhttp.responseText;
}


function Test(){
alert('An External JavaScript\nhas not been Added');
}

/*]]>*/
</script>

</head>

<body>
<input type="button" name="" value="Add JS fred.js" onclick="AddJS('fred.js');" /><br />
<input type="button" name="" value="Add JS tom.js" onclick="AddJS('tom.js');" /><br />
<input type="button" name="" value="Test" onclick="Test();" />
<br />
<br />
<input type="button" name="" value="Add CSS ss1.css" onclick="AddCSS('ss1.css');" /><br />
<input type="button" name="" value="Add CSS ss2.css" onclick="AddCSS('ss2.css');" /><br />
<span class="color" >Some Test Text</span>
</body>

</html>

nospirit
12-27-2005, 01:06 PM
Dear Buddy
that's dosen't work
you allready replyied me..thanks any way



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum