繁体   English   中英

Javascript在FF和IE弹出窗口中不起作用

[英]Javascript not working in FF and IE popup window

嗨,大家好,我在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对象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM