How to implement dynamic deletion of JavaScript functions _javascript techniques
Source: Internet
Author: User
I am now through the following:
O=odom.createelement ("script");
O.text=document.all.checkrule.value;
ODOM.body.appendChild (o);
You can add a checkrule function,
But I do this code multiple times to insert this checkrule function, so how do I remove the new function first?
Ps:odom represents the Document object for another page, not the document on this page, so typeof (Odom.check_rule) always undefined
ODOM.frames.check_rule = null
Functions with the same name are overwritten.
You can use this ID or name when you add an ID or name to the newly added SCRIPT and then delete it.
But remember, be sure to set the ID or NAME in the CreateElement method
For example: o = document.createelement ("<script language= ' javascript ' id= ' aaa ' >" + "</SCR" + "ipt>");
Thank you so much.
Synthetic checksum rules
function Docombjs () {
var oeditor = fckeditorapi.getinstance (' FCKeditor1 ');
var ODOM = oeditor.editordocument;
var Elem=odom.getelementbyid ("Checkid");
alert (elem);
if (elem!=null) {
Elem.parentNode.removeChild (Elem);
}
o = Odom.createelement ("<script language= ' javascript ' id= ' Checkid ' >" + "</SCR" + "ipt>");
O=odom.createelement ("script");
O.text=document.all.checkrule.value;
ODOM.body.appendChild (o);
}
Boss, there's a problem.
If I don't use Odom.createelement ("<script language= ' javascript ' id= ' Checkid ' >" + "</SCR" + "ipt>"); and directly to write this, I use Var Elem=odom.getelementbyid ("Checkid");
Why get is NULL, must use above createelement, just can find this ID, please help again, thank you!
You mean:
You write <script language= ' javascript ' id= ' Checkid ' ></script> directly on the page, but you use the following statement var Elem=odom.getelementbyid (" Checkid "); The object cannot be obtained, is it?
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service