嗨,伙计们,我在Firefox和IE上遇到了一些奇怪的问题。在此之前我还没有遇到过这样的问题,所以请帮助。我做了一个自定义的图像浏览器来与ckeditor一起使用。浏览器(弹出窗口)窗口按预期打开,但是当我尝试返回fileUrl或运行任何类型的javascript时,Firefox和IE没有任何反应。铬一切都很好。
浏览器页面代码:
<?php
$path = "./public/user_images/demo_user/";
if(is_dir($path) == true){
$list = scandir($path);
if(count($list) >= 1){
foreach ($list as $key=>$value) {
if(is_file($path.$value)){
$file = base_url($path.$value);
echo <<<start
<button class="btn_browser_img">
<img src="$file" class='browser_img'><img>
</button>
start;
}
}
}
}else{
echo "Oops! Wrong folder...";
}
?>
后台Javascript:
$(".browser_img").click(
function(){
alert(this.getAttribute('src'));
fileUrl = this.getAttribute('src');
sendFileUrl(fileUrl);
}
);
function sendFileUrl(fileUrl){
window.opener.CKEDITOR.tools.callFunction( funcNum, fileUrl );
window.close();
}
this.getAttribute(...)
将不起作用,因为这对应于包装器 jQuery 对象。
所以试试this[0].getAttribute(...)
jQuery将实际对象存储在第0个位置,因此this[0]
会给你DOM对象。