cant invoke a function loaded thru a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newlearner
    New Member
    • May 2007
    • 67

    cant invoke a function loaded thru a string

    Hi,
    I load some javascript functions through a string in to a div of a html file

    also i set an onclick event to a td thru setAttribute.

    This works fine if there is just an alert or a scripts without functions (in this case the string is passed asit is).

    the string is with function and statement inside it is written inside a div with creating script tags at he begging and end . Now When i assing the function to the td thru setAttribute the function inside the div is not called.

    I tried it to insert into the Head tag also even then its not working.

    the error is : the function is not defined.


    Any Suggestions PLS
    .... Looking Forward.
  • newlearner
    New Member
    • May 2007
    • 67

    #2
    Originally posted by newlearner
    Hi,
    I load some javascript functions through a string in to a div of a html file

    also i set an onclick event to a td thru setAttribute.

    This works fine if there is just an alert or a scripts without functions (in this case the string is passed asit is).

    the string is with function and statement inside it is written inside a div with creating script tags at he begging and end . Now When i assing the function to the td thru setAttribute the function inside the div is not called.

    I tried it to insert into the Head tag also even then its not working.

    the error is : the function is not defined.




    Any Suggestions PLS
    .... Looking Forward.

    The Code
    ***********

    function external(){
    var headID = document.getEle mentsByTagName( "head")[0];
    var newScript = document.create Element('script ');
    newScript.type = 'text/javascript';
    newScript.onloa d = testfn;
    headID.appendCh ild(newScript);
    }

    if (xmlhttp.readyS tate == 4){
    var response = xmlhttp.respons eText;
    var thisdoc = xmlhttp.respons eXML;
    var domParser = new DOMParser();
    var xmlroot = domParser.parse FromString(resp onse,'applicati on/xml');
    if(xmlroot.sele ctSingleNode("//ProductsData/test")){
    testfn = xmlroot.selectS ingleNode("//ProductsData/test/text()").nodeVa lue;
    external();
    document.getEle mentById("conte nt1").setAttrib ute("onClick",x mlTest());
    }
    }

    Thanks in advance..
    Looking Forward for a reply

    Comment

    Working...