(function($){
var screen_width = 0;
var screen_scroll = 0;
var help_width = 0;
var help_height = 0;
var help_cont = '';
var help_offset = 0;
var help_html = '';
var hover_status = false;
$(".helpme").live("mouseenter",function(){
hover_status = true;
screen_width = $("body").width();
screen_scroll = $(window).scrollTop();
help_cont = $(this).attr("help");
help_offset = $(this).offset();
help_html = '<div id="helper_back"></div><div id="helper"><div id="helper_cont">';
help_html += '';
help_html += '</div></div>';
$("body").append(help_html);
calc_size();
$(this).bind("mouseleave",function(){
$("#helper_back").css("top",-9999).remove();
$("#helper").remove();
hover_status = false;
});
});
$(document).bind("mousemove",function(e){
if(hover_status === true) {
calc_size();
var local_left = e.pageX + 20;
var local_top = e.pageY - help_height - 15;
if(local_left + help_width > screen_width - 20) {
local_left = screen_width - 20 - help_width;
}
if(local_top < screen_scroll) {local_top = e.pageY + 20};
$("#helper_back").css("left",local_left).css("top",local_top);
$("#helper").css("left",local_left + 3).css("top",local_top + 3);
$("#helper_cont").css("visibility","visible");
}
});
function calc_size() {
help_width = $("#helper").width();
help_height = $("#helper").height();
if(help_width > 300) {help_width = 300};
$("#helper_back").width(help_width).height(help_height);
$("#helper").width(help_width);
}
})(jQuery);
我一直在嘗試修改此代碼,所以我可以用ajax構建help_html。首先將文件(test.html)讀取爲字符串時遇到一些問題。其次,我試圖在Chorme和歌劇中打開它並不工作。任何建議爲什麼這個腳本不適用於Chrome和Opera,但在Mozilla中工作?不工作在鉻和歌劇在莫吉拉工作
你能幫我一下哪一部分不能正常工作嗎? – 2011-12-15 11:16:42