0

我正在使用 swfupload 插件(http://demo.swfupload.org/Documentation/)上传多个文件。我定义了以下 swfupload 设置对象。一切正常,除了光标没有变成“手”形。这是代码:

var initialize_swfupload_for_image = function () {

if ($('#image-attach').length == 0){
  return;
}
var url = $('#image-attach').data('url');
var params = $('#image-attach').data('params');
var buttonStyle = '.image-link {color: #FFF' +
                ';text-align: center'+
                ';} ' +
                '.image-link:hover {color: #0FF' +
                ';} ';
var settings = {
  upload_url:url,
  flash_url: "<%= asset_path('swfupload/swfupload.swf') %>",
  flash9_url: "<%= asset_path('swfupload/swfupload_fp9.swf') %>",
  http_success:[ 200, 201, 204 ],
  file_post_name:"file",
  file_types: "*.jpg; *.gif; *.png; *.jpeg",
  file_upload_limit:1,
  file_queue_limit:0,
  file_size_limit:"10 MB",
  prevent_swf_caching:false,
  custom_settings:{
    progressTarget:"divImageProgressContainer",
    cancelButtonId:"btnImageCancel"
  },
  button_placeholder_id:"image-attach",
  button_text: "<span class='image-link'>Edit Photo</span>",
  button_text_style: buttonStyle,

  button_width: 90,
  button_height: 20,
  button_cursor:SWFUpload.CURSOR.HAND,
  button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,
  button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,

  file_queued_handler:fileQueued,
  file_queue_error_handler:fileQueueError,
  file_dialog_complete_handler:fileDialogComplete,

  upload_start_handler:uploadStartImage,
  upload_error_handler:uploadError,
  upload_progress_handler:uploadProgressImage,
  upload_success_handler:uploadSuccessImage,
  upload_complete_handler:uploadCompleteImage,
  queue_complete_handler:uploadCompleteImage,

  post_params:params
};
if (FlashDetect.versionAtLeast(9)) {
  swf_image = new SWFUpload(settings);
} else {
  //intentionally left blank
  //TODO: javascript fallback when swfupload doesn't work
}

任何关于为什么光标在悬停在对象上时没有改变的见解都会非常有帮助。

4

1 回答 1

1

我也遇到过同样的问题。就我而言,罪魁祸首是我不小心添加到button_widthandbutton_height属性中的“px”:button_width: "20px".

您的问题显然不是同一个问题,但可能与您向 SWFUpload 传递了无效值有关。

我复制了您的代码,在从自定义内容中清除它之后,我毫不费力地展示了手(甚至没有改变任何东西)。这是使用 swfupload.swf 2.2.0.1 和 swfupload.js 2.2.0 2009-03-25 测试的代码(请注意,swfupload.swf 和 swfupload.js 与 html 文件位于同一文件夹中):

<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>index</title>
    <script type="text/javascript" src="swfupload.js"></script>
    <script type="text/javascript" charset="utf-8">
    var init = function () {

    var settings = {
      upload_url:'url',
      flash_url: "swfupload.swf",
      http_success:[ 200, 201, 204 ],
      file_post_name:"file",
      file_types: "*.jpg; *.gif; *.png; *.jpeg",
      file_upload_limit:1,
      file_queue_limit:0,
      file_size_limit:"10 MB",
      prevent_swf_caching:false,
      custom_settings:{
        progressTarget:"divImageProgressContainer",
        cancelButtonId:"btnImageCancel"
      },
      button_placeholder_id:"image-attach",
      button_text: "<span class='image-link'>Edit Photo</span>",

      button_width: 90,
      button_height: 20,
      button_cursor:SWFUpload.CURSOR.HAND,
      button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,
      button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,

    };
      swf_image = new SWFUpload(settings);
  }
    </script>

</head>
<body id="index" onload="init()">
    <div style="width:100px;height:100px;background-color:blue">
    <div id="image-attach"></div>
    </div>
</body>
</html>

我的猜测仍然是 SWFUpload 可能不喜欢其中一个参数(例如<%asset东西)。无论如何,希望这会有所帮助。

于 2012-08-14T14:38:11.253 回答