By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,717 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,717 IT Pros & Developers. It's quick & easy.

cant invoke a function loaded thru a string

P: 67
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.
Jun 18 '07 #1
Share this Question
Share on Google+
1 Reply


P: 67
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.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.onload = testfn;
headID.appendChild(newScript);
}

if (xmlhttp.readyState == 4){
var response = xmlhttp.responseText;
var thisdoc = xmlhttp.responseXML;
var domParser = new DOMParser();
var xmlroot = domParser.parseFromString(response,'application/xml');
if(xmlroot.selectSingleNode("//ProductsData/test")){
testfn = xmlroot.selectSingleNode("//ProductsData/test/text()").nodeValue;
external();
document.getElementById("content1").setAttribute(" onClick",xmlTest());
}
}

Thanks in advance..
Looking Forward for a reply
Jun 18 '07 #2

Post your reply

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