Opened 14 years ago
Last modified 10 years ago
#7927 closed Bug
bbcode and js event problem — at Version 1
Reported by: | zleaf | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 3.6 |
Keywords: | Cc: |
Description (last modified by )
for example: after paste a image in ckeditor in bbcode mode, (the image is like :
<img src="http://cksource.com/forums/images/smilies/icon_e_biggrin.gif" onclick="alert('abc')">
), then click the View Source button, error occur...
here's my way to fix this problem, hoping the official way
function purge(d){ var a=d.attributes,i,l,n; if(a){ l=a.length; for(i=0;i<l;i+=1){ n=a[i].name; if(typeof d[n]==='function'){ d[n]=null; } } } a=d.childNodes; if(a){ l=a.length; for(i=0;i<l;i+=1){ purge(d.childNodes[i]); } } } editor.on( 'insertHtml', function(data){ var t=document.createElement('div'); document.body.appendChild(t); t.innerHTML = data.data; purge(t); data.data = t.innerHTML; document.body.removeChild(t); });