【问题标题】:Javascript not working in FF and IE popup windowJavascript 在 FF 和 IE 弹出窗口中不起作用
【发布时间】:2014-02-19 13:20:52
【问题描述】:

大家好,我在使用 Firefox 和 IE 时遇到了一些奇怪的问题。在此之前我没有遇到过这样的问题,所以请帮忙。我制作了一个自定义图像浏览器来使用 ckeditor。浏览器(弹出窗口)窗口按预期打开,但是当我尝试返回 fileUrl 或运行任何类型的 javascript 时,Firefox 和 IE 没有任何反应。 chrome 一切正常。

浏览器页面代码:

<?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();
}

【问题讨论】:

    标签: javascript internet-explorer firefox ckeditor popupwindow


    【解决方案1】:

    this.getAttribute(...) 将不起作用,因为它对应于包装 jQuery 对象。

    那就试试this[0].getAttribute(...)

    jQuery 将实际对象存储在第 0 个位置,因此 this[0] 将为您提供 DOM 对象。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 1970-01-01
    • 2013-04-12
    • 2012-12-05
    相关资源
    最近更新 更多