Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Loading JS in the same id place..PLZ HELP

    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

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    Code:
    <!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>

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dear Buddy
    that's dosen't work
    you allready replyied me..thanks any way


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •