我正在写一个模态弹出窗口,当按下打开模态按钮时我需要浏览器跳到屏幕顶部.有没有办法使用jQuery将浏览器滚动到顶部?
第一个问题:
说我有
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
string storedProc = "GetData";
SqlCommand command = new SqlCommand(storedProc, connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@EmployeeID", employeeID));
return (byte[])command.ExecuteScalar();
}
Run Code Online (Sandbox Code Playgroud)
连接是否关闭?因为从技术上讲,我们永远不会}像return以前那样到达最后.
第二个问题:
这次我有:
try
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
int employeeID = findEmployeeID();
connection.Open();
SqlCommand command = new SqlCommand("UpdateEmployeeTable", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@EmployeeID", employeeID));
command.CommandTimeout = 5;
command.ExecuteNonQuery();
}
}
catch (Exception) { /*Handle error*/ }
Run Code Online (Sandbox Code Playgroud)
现在,说出来try我们得到一个错误,它被抓住了.连接是否仍然关闭?因为我们再次跳过其余代码try并直接转到catch …
你好,如果我在PHP中有street_name,State_name,City_name,Country_name和邮政编码,那么获取任何地址的经度和纬度的是什么?谢谢
我需要一个算法来解决这个问题:给定2个在任何角落交叉或重叠的矩形,如何确定没有重叠(交叉)区域的两个矩形的总面积?意味着必须使用第一个矩形或第二个矩形计算一次交叉区域.
我讨厌W3C和MS创建的鼠标按钮!我想知道当我得到一个mousedown事件时是否按下了鼠标左键.
我用这个代码
// Return true if evt carries left mouse button press
function detectLeftButton(evt) {
// W3C
if (window.event == null) {
return (evt.button == 0)
}
// IE
else {
return (evt.button == 1);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,它在Opera和Chrome中不起作用,因为它也发生在window.event中.
那我该怎么办?我有一些浏览器检测,但我们都知道它不能依赖于某些浏览器最近做的所有屏蔽.如何检测鼠标左键RELIABLY?
插入<li>...</li>页面而不将项目封入<ul>块中有什么危险?例如:
<div style="border:solid 1px red;">
<li>Item</li>
<li>Another Item</li>
<li>Yet Another Item</li>
</div>
Run Code Online (Sandbox Code Playgroud)
验证是我最不关心的问题,我想知道在浏览器中这可能会破坏最终用户按预期查看页面的能力.
我有一个特殊类"地方"的跨度列表,其中一些有"激活"类.有没有办法选择"激活"类和最后一个类的第一个项目?
<span class="place" onclick="activate();">1</span>
<span class="place" onclick="activate();">2</span>
<span class="place activated" onclick="activate()">3</span>
<span class="place activated" onclick="activate();">4</span>
<span class="place activated" onclick="activate();">5</span>
<span class="place activated" onclick="activate();">6</span>
<span class="place" onclick="activate();">7</span>
Run Code Online (Sandbox Code Playgroud) 我读这篇文章由布兰登·艾伦在这里,关于jQuery的背景下可能会怎样帮助.所以我想做一个自己的测试.所以这就是我所做的.
在前面创建的"#context"中创建了一个id ="context"的DIV和嵌套的DIV,id ="holder".
创建了深度为18的嵌套DIV并附<div id="context"><div id="holder"></div></div>加到其上,从而生成20个嵌套DIV
现在我测试了通过以下选择器访问"#holder"所花费的时间:
a.$("#holder") // no context
湾 $("#holder", "#context") // with "#context" selector string
C.$("#holder", $("#context")) // sending jquery object each time with selector "#context"
d.$("#holder", $context) // where, var $context = $("#context"). Caching jquery obj
记录了访问X = 1000时间和开始和结束时间差异的每种情况.我发现所花费的时间:
情况(a)是最不一致的28-32毫秒[jquery-1.3.2]
情况(b)+(c)分别具有60-65毫秒和70-75毫秒的最高时间
(d) )有40到50毫秒,有1或2个加标值.
这种基本检查有效吗?你可以用JS代码打这里的JSBIN.[让我知道如果我可以改进这个测试一些如何]
如果是,那么这个'背景'真的有用吗?
#NOTE:在jsbin编辑模式下用jquery-1.4.2替换jquery-1.3.2,你会惊讶地看到数字突然增加:P
javascript ×3
jquery ×3
c# ×2
html ×2
algorithm ×1
android ×1
css ×1
html-lists ×1
key ×1
modal-dialog ×1
mouseevent ×1
opera ×1
performance ×1
php ×1
using ×1
xml ×1