我無法找到一個乾淨的解決方案,讓CKEditor將href="javascript:void(0)"
保存在我放置在我的小部件模板中的鏈接中。當我保存它時,通過調用CKEDITOR.instances.*.getData()
,它返回href="javascript void(0)"
。CKEditor如何在小部件中允許href =「javascript:void(0)」
我已經嘗試設置在config.js config.allowedContent = true;
& config.linkJavaScriptLinksAllowed = true;
,但他們似乎都沒有做任何事情...
我已閱讀this page它表示這應該是固定的,但是這並不工作。有任何想法嗎?
下面是有趣的簡化plugin.js部分。這允許鏈接中的href
屬性,但它仍會去掉:
。
template:
'<div class="container">' +
'<a href="javascript:void(0)">' +
'<span class="label">Label</span>' +
'</a>' +
'</div>',
allowedContent:
'a[href]; div(*); span(*);',
editables: {
Label: {
selector: '.label',
allowedContent: ''
}
}
CKEditor的版本:4.5.9 瀏覽器:Chrome的
感謝您發佈!然而,這不起作用,問題是沒有得到一個href屬性,但在href中的JavaScript。我用一些代碼更新了我的答案,使其更清晰 – Bastiaan
@Bastiaan感謝您的澄清。你能告訴我你在使用哪種瀏覽器嗎?上面設置的'javascript:void(0)'似乎在Chrome中工作正常。 – f1ames
我使用Chrome ... :(你測試它,它的工作原理?? – Bastiaan