在这里,我有一个表格,第一个单元格的每一行都包含一个可向右扩展的 Div,这里的 div 位于第一个单元格 id(R1Date1) 中,当我将其扩展到第二个单元格时,我需要提醒第二个单元格 id (R1Date2) 和下面的 Div Id(Book1) 是我尝试过的代码,但它无法正常工作,因为我对 Jquery 事件不太熟悉
window.console = window.console || function(t) {};
if (document.location.search.match(/type=embed/gi)) {
window.parent.postMessage("resize", "*");
}
window.onload = function() {
initDragElement();
initResizeElement();
};
function initDragElement() {
var pos1 = 0,
pos2 = 0,
pos3 = 0,
pos4 = 0;
var popups = document.getElementsByClassName("popup");
var elmnt = null;
var currentZIndex = 100; //TODO reset z index when a threshold is passed
for (var i = 0; i < popups.length; i++) {
if (window.CP.shouldStopExecution(0)) break;
var popup = popups[i];
var header = getHeader(popup);
popup.onmousedown = function() {
this.style.zIndex = "" + ++currentZIndex;
};
if (header) {
header.parentPopup = popup;
header.onmousedown = dragMouseDown;
}
}
window.CP.exitedLoop(0);
function dragMouseDown(e) {
elmnt = this.parentPopup;
elmnt.style.zIndex = "" + ++currentZIndex;
e = e || window.event;
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
if (!elmnt) {
return;
}
e = e || window.event;
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
elmnt.style.top = elmnt.offsetTop - pos2 + "px";
elmnt.style.left = elmnt.offsetLeft - pos1 + "px";
}
斯蒂芬大帝
相关分类