我正在使用Jquery Cluetip作为我的工具提示。工具提示内容通过 Cluetip 中的 AJAX 功能加载。在加载的内容中,我想使用 Javascript 来增加可用性。
索引.html:
<img src="edit.png" title="Test" class="popup" rel="ajax-content.html">
onLoad.js:
$('.popup').cluetip({activation: 'click'});
ajax-content.html:
<script language="javascript" type="text/javascript">
alert('Hello world!');
</script>
Test content.
结果是在单击时出现一个工具提示,标题为:'测试',内容:'测试内容'并且没有警报说'你好世界!'。FireBug 不显示脚本或控制台错误。
对此有什么帮助吗?
编辑:
我想到了。
Cluetip 在处理 ajax 上有一个默认操作:
ajaxProcess: function(data) {
data = data.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm, '').replace(/<(link|meta)[^>]+>/g,'');
return data;
}
所以解决方法是:
$('.popup').cluetip({
activation: 'click'.
ajaxProcess: function(data) {
return data;
}
});
我不确定为什么 Cluetip 会删除所有脚本/样式/标题,可能是为了防止错误。