Chrome调试控制台未显示此代码的“脚本”标签

时间:2012-12-31 05:41:07

标签: javascript google-chrome console

Chrome调试控制台(Chrome版本23.0.1271.97)未显示此代码的“脚本”标签。我有一个更复杂的代码需要调试,但是,我必须通过Chrome控制台问题,所以我提供了这个示例。任何帮助都将不胜感激。谢谢!

<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Draggable objects</title>
<script type="text/javascript">

var bMouseUp = true, oDragging, nMouseX, nMouseY, nStartX, nStartY, nZFocus = 100 /* the highest z-Index present 

in     your page plus 1 */;

function dragDown(oPssEvt1) {
var bExit = true, oMsEvent1 = oPssEvt1 || /* IE */ window.event;
for (var iNode = oMsEvent1.target; iNode; iNode = iNode.parentNode) {
if (iNode.className === "draggable") { bExit = false; oDragging = iNode; break; }
}
if (bExit) { return; }
bMouseUp = false;
nStartX = nStartY = 0;
for (var iOffPar = oDragging; iOffPar; iOffPar = iOffPar.offsetParent) {
nStartX += iOffPar.offsetLeft;
nStartY += iOffPar.offsetTop;
}
nMouseX = oMsEvent1.clientX;
nMouseY = oMsEvent1.clientY;
oDragging.style.zIndex = nZFocus++;
return false;
}

function dragMove(oPssEvt2) {
if (bMouseUp) { return; }
var oMsEvent2 = oPssEvt2 || /* IE */ window.event;
oDragging.style.left = String(nStartX + oMsEvent2.clientX - nMouseX) + "px";
oDragging.style.top = String(nStartY + oMsEvent2.clientY - nMouseY) + "px";
}

function dragUp() { bMouseUp = true; }

document.onmousedown = dragDown;
document.onmousemove = dragMove;
document.onmouseup = dragUp;

</script>


<style type="text/css">
.draggable {
position: fixed;
left: 0;
top: 0;
width: auto;
height: auto;
cursor: move;
}

#myDiv {
width: 300px;
height: 200px;
left: 200px;
top: 200px;
background-color: #00ff00;
}
</style>
</head>

<body>

1 个答案:

答案 0 :(得分:0)

我的Chrome版本是版本25.0.1364.5 dev。并在Max osX

所以,我猜,你的HTML-dom结构会出现问题。 如果没有,您可以打开Tab-“sources”,然后选择要调试的文件(窗口左侧的Sources)。

鼠标事件太多了,你可以考虑在chrome上进行“远程调试”

https://developers.google.com/chrome-developer-tools/docs/remote-debugging