Home  >  Article  >  Web Front-end  >  How to dynamically delete javascript functions_javascript skills

How to dynamically delete javascript functions_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:13:011412browse

I now pass the following: o = odom.createelement ("script");
o.text = document.all.checkrule.value;
oiduom.body.appendchild (o);
Add a checkrule function,
But if I execute this code multiple times, the checkrule function will be inserted multiple times. How can I delete the new function first?
ps: oDOM represents the document object of another page. , not the document of this page, so using typeof(oDOM.check_rule) is always undefined

oDOM.frames.check_rule = null
The function with the same name will be overwritten.
You add an ID or NAME to the newly added SCRIPT, and then you can use the ID or NAME when deleting it
But remember, you must set the ID or NAME in the createElement method

For example: o = document.createElement("
, but you cannot get the object through the following statement var elem=oDOM.getElementById("checkid");, right?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn