3

我遇到了可拖动的问题。我正在制作一个窗口管理器式的系统,并希望拥有它,因此只能通过标题栏拖动窗口。问题是,出于某种原因,它不想做它应该做的事情。即使我清楚地将手柄设置为标题栏,它也允许我拖动所有内容。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="CSS/Primary.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="javascript/jquery-1.8.2.js">
</script>
<script type="text/javascript" src="javascript/jquery-ui-1.8.24.custom.min.js">
</script>

<script type="text/javascript">
$(document).ready(function(){
  $("#LoginMinimize").click(function(){
    $("#divLoginBox").toggle();
  });
   $("#LoginClose").click(function(){
    $("#LoginContainer").remove();
  });
$( "#divLoginTitleBar" ).draggable({
    containment: 'window',
    scroll: false,
    handle: '#divLoginTitleBar'

});
});
</script>

<title>HEP Online --- Application Platform</title>

</head>

<body>

<div class="LoginContainer" id="LoginContainer">
<div id="divLoginTitleBar" class="TitleBar">
    Login <div id="divTitleButtonBox" class="TitleButtonBox">
        <img src="images/minimize.png" id="LoginMinimize" height="24px" /> 
        <img src="images/close.png" id="LoginClose" height="24px" /></div>

<div id="divLoginBox" class="LoginBox">
<div id="divLoginContent" class="LoginContent">

<form method="post" action="" id="frmLogin">

<img src="images/loginsplash.png" />

    <table id="tblLoginContent" class="LoginContent">
        <tr>
            <td>Username:</td>
            <td>
            <input maxlength="50" name="txtUsrName" size="20" type="text" /></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td>
            <input maxlength="24" name="txtPassword" size="20" type="password" /></td>
        </tr>
        <tr>
            <td><input name="btnLogin" type="submit" value="Login" /></td>
            <td><input name="btnReset" type="reset" value="Reset" /></td>
        </tr>
    </table>
    </form>
</div>
</div>
</div>
</div>

</body>

</html>
4

1 回答 1

2

标题栏包含所有其他元素,因此它们也是可拖动的。您需要将所有内容包装在 div 中并将标题栏设置为句柄。

因此,您必须更改 js 以使包装 div 可拖动:

$( "#divLoginWindow" ).draggable({
containment: 'window',
scroll: false,
handle: '#divLoginTitleBar'
});

当然,还要创建那个 div。

<div id="divLoginWindow">
<div id="divLoginTitleBar" class="TitleBar">
Login
</div> <div id="divTitleButtonBox" class="TitleButtonBox">
    <img src="images/minimize.png" id="LoginMinimize" height="24px" /> 
    <img src="images/close.png" id="LoginClose" height="24px" /></div>
....
于 2012-10-05T01:34:41.827 回答