safari下div不能相应鼠标事件的问题!
function OnGenSchedule(bg_div, title)
{
var title_div = 0;
var tick_div = 0;
var schedule_div = 0;
var strInnerHTML = "";
var strSubInnerHTML = "";
//创建标题
title_div = document.createElement("div");
title_div.style.cssText = "left:0px;top:0px;border:solid 1px;height:15px;width:63px;position:absolute;text-align:center";
title_div.innerHTML = title;
strInnerHTML += title_div.outerHTML;
if(g_schuduleHTML == "")
{
//创建刻度
tick_div = document.createElement("div");
tick_div.style.cssText = "left:65px;top:0px;width:672px;height:16px;position:absolute";
var tick_cell_div = document.createElement("div");
strSubInnerHTML = "";
for(var i = 0; i < 672; i += 112)
{
tick_cell_div.style.cssText = "width:112px;height:16px;top:0px;position:absolute;z-index:2;border-right:solid 1px;border-top:solid 1px;text-align:left;";
tick_cell_div.style.left = i + "px";
tick_cell_div.innerText = " " + AlignTime(i / 28) + ":00";
strSubInnerHTML += tick_cell_div.outerHTML;
}
tick_div.innerHTML = strSubInnerHTML;
g_schuduleHTML += tick_div.outerHTML;
//创建排程设置区域
schedule_div = document.createElement("div");
schedule_div.style.cssText = "left:64px;top:16px;width:672px;height:20px;position:absolute;border:solid 1px";
var schedule_item_div = 0;
schedule_item_div = document.createElement("div");
schedule_item_div.style.cssText = "width:7px;height:20px;top:0px;position:absolute;background-color:#e0e0e0;z-index:1";
schedule_item_div.onmouseover = "OnDragging(this)";
schedule_item_div.onmousedown = "OnStartSchedule(this)";
strSubInnerHTML = "";
for(var i = 0; i < 672; i += 7)
{
schedule_item_div.style.left = i + "px";
strSubInnerHTML += schedule_item_div.outerHTML;
}
schedule_div.innerHTML = strSubInnerHTML;
g_schuduleHTML += schedule_div.outerHTML;
}
//创建时间选择提示框
var time_tip_div = document.createElement("div");
time_tip_div.style.cssText = "left:0px;top:16px;border:solid 1px;height:20px;width:63px;position:absolute;text-align:center;background-color:#CCBBFF;display:none;";
time_tip_div.innerHTML = "";
strInnerHTML += time_tip_div.outerHTML;
strInnerHTML += g_schuduleHTML;
bg_div.innerHTML = strInnerHTML;
}
这个函数用创建一行div组,每个div都有onmouseover,onmousedown 相应事件,在IE下运行这两个事件都可以相应,但是在safari下,我在这两个事件相应函数里面第一行打对话框,都没有显示。说明这两个函数都没有相应。不知道怎么回事?
------解决方案--------------------
schedule_item_div.onmouseover = "OnDragging(this)";
schedule_item_div.onmousedown = "OnStartSchedule(this)";
这种方式没用过,可能是这里出的问题。
改成这样试试:
schedule_item_div.onmouseover =function(){
OnDragging(this);
}
schedule_item_div.onmousedown = function(){
OnStartSchedule(this);
}
this指向的是schedule_item_div这个对象