我正在从这个页面学习javascript示例,
http://nofunc.org/AJAX_Star_Rating
我对函数XY(e,v)中的以下代码片段感到困惑,特别是两个语句,event.clientX+document.documentElement.scrollLeft并且
event.clientY+document.documentElement.scrollTop,任何人都可以告诉我什么是document.documentElement.scrollLeft和document.documentElement.scrollTop?为什么我们将它添加到event.clientX并event.clientY取悦(即将它们添加到event.clientX和时我们可以得到什么有意义的值event.clientY)?
顺便说一句:我正在使用Internet Explorer.
乔治,提前谢谢
我今天刚刚将一个站点转换为Blueprint CSS,突然我的所有超链接都在括号中显示了它们的URL,例如
这个超链接
<a href="Products/List.aspx">Read more</a>
Run Code Online (Sandbox Code Playgroud)
像这样渲染
Read More (Products/List.aspx)
Run Code Online (Sandbox Code Playgroud)
我想知道这是否与Blueprint中的捆绑插件有关?
增加:链接正常呈现,即不需要的URL部分是在客户端生成的.人们要求提供源代码,所以这里是(删除了不相关的文本):
<!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>
<title></title>
<link href="Styles/Blueprint/screen.css" rel="stylesheet" type="text/css" />
<link href="Styles/Blueprint/print.css" rel="stylesheet" type="text/css" />
<!--[if lt IE 8]><link rel="stylesheet" href="Styles/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
</head>
<body>
<a href="Products/List.aspx">Read more</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
已解决: 通过删除所有教程建议包括的'print.css'表,我能够解决此示例和我的整个站点中的问题.我仍然很好奇为什么古老的'print.css'就是这样表现的.
我需要从带有正则表达式的mailto属性的锚点获取电子邮件地址.
这种模式: (.*)<a\s(.*?)(.*)\s*href\=['"]mailto:([-a-z0-9_]+)@([a-z0-9-]+).([a-z]+)['"]>(.*)</a>(.*)
在regex教练中工作,虽然它不适用于PHP.
码:
preg_match("'(.*)<a (.*?)(.*) *href\=['\"]mailto:([-a-z0-9_]+)@([a-z0-9-]+).([a-z]+)['\"]>(.*)</a>(.*)'si", "<a href=\"mailto:someemail@ohio.com\"">Some email</a>", $matches);
print_r($matches);
Run Code Online (Sandbox Code Playgroud)
那么为什么要在php中工作呢?
看看这个(可以说是愚蠢的)代码:
public <T extends Appendable & Closeable> void doStuff(T object)
throws IOException{
object.append("hey there");
object.close();
}
Run Code Online (Sandbox Code Playgroud)
我知道编译器删除了通用信息,所以我对编译器所做的Java 1.4代码感兴趣(我很确定编译器没有重新安排源代码,所以我要求一个等效的Java源代码版本像我这样天真的人可以理解)
是这样的:
public void doStuff(Object object)
throws IOException{
((Appendable)object).append("hey there");
((Closeable)object).close();
}
Run Code Online (Sandbox Code Playgroud)
或者更喜欢这样:
public void doStuff(Object object)
throws IOException{
Appendable appendable = (Appendable) object;
Closeable closeable = (Closeable) object;
appendable.append("hey there");
closeable.close();
}
Run Code Online (Sandbox Code Playgroud)
或者甚至像这样:
public void doStuff(Appendable appendable)
throws IOException{
Closeable closeable = (Closeable) appendable;
appendable.append("hey there");
closeable.close();
}
Run Code Online (Sandbox Code Playgroud)
还是另一个版本?
我正在尝试创建一个程序,使用sql命令更新2个不同的表.我唯一担心的是,如果程序更新其中一个表然后失去连接或其他什么,并且不更新另一个表,则可能存在问题.我有办法吗?
A.在同一时间更新它们
要么
B.如果第二次更新失败,则还原第一次更新.
我可以任意属性为JavaScript DOM对象,如添加<INPUT>或<SELECT>元素?或者,如果我不能这样做,有没有办法通过引用属性将我自己的对象与页面元素相关联?
我一直在尝试清除所有cookie中的代码HttpContext.Response.
最初,我使用了这个:
DateTime cookieExpires = DateTime.Now.AddDays(-1);
for (int i = 0; i < HttpContext.Request.Cookies.Count; i++)
{
HttpContext.Response.Cookies.Add(
new HttpCookie(HttpContext.Request.Cookies[i].Name, null) { Expires = cookieExpires });
}
Run Code Online (Sandbox Code Playgroud)
但是,这会导致错误,OutOfMemoryException因为for循环永远不会退出 - 每次添加cookie时Response,它都会被添加到`Request.
以下方法有效:
DateTime cookieExpires = DateTime.Now.AddDays(-1);
List<string> cookieNames = new List<string>();
for (int i = 0; i < HttpContext.Request.Cookies.Count; i++)
{
cookieNames.Add(HttpContext.Request.Cookies[i].Name);
}
foreach (string cookieName in cookieNames)
{
HttpContext.Response.Cookies.Add(
new HttpCookie(cookieName, null) { Expires = cookieExpires });
}
Run Code Online (Sandbox Code Playgroud)
那么,HttpContext.Request.Cookies和之间的关系到底是什么HttpContext.Response.Cookies?
我有一个用java编写的Web应用程序.我希望运行一个"清理"方法,该方法将在每个Web请求结束时运行,就像在完成所有工作之后一样.我正在寻找类似于过滤器的东西,只是它会在请求结束时而不是在开始时运行.
这样做的方法是什么?
任何帮助,将不胜感激
当然,问题是红宝石符号不喜欢连字符.所以这样的东西显然不会起作用:
content_tag(:div, "Some Text", :id => "foo", :data-data_attr => some_variable)
Run Code Online (Sandbox Code Playgroud)
一种选择是使用字符串而不是符号:
content_tag(:div, "Some Text", :id => "foo", 'data-data_attr' => some_variable)
Run Code Online (Sandbox Code Playgroud)
或者我可以插入:
"<div id='foo' data-data_attr='#{some_variable}'>Some Text</div>".html_safe
Run Code Online (Sandbox Code Playgroud)
我更喜欢后者,但两者看起来都有点粗糙.谁知道更好的方法?
我目前正在进行简单的数据签名.这是我第一次使用签名,所以也许我只是做错了.但我不认为使用512位RSA和SHA1散列签署448字节需要4.6秒才是正常的.
代码:
byte[] Data = enc.GetByte(MsgString); //Get Message as byte[]
//Data is 448 bytes long
RSACryptoServiceProvider Crypter = new RSACryptoServiceProvider(512);
Crypter.ImportCspBlob(Convert.FromBase64String(KeyString));
byte[] SignedData = Crypter.SignData(Data, "SHA1"); //Line takes 4.6 seconds
Run Code Online (Sandbox Code Playgroud)
为什么这么慢?我发现了这个:http://support.microsoft.com/kb/948080,但那是.NET 2.0的一个问题.我正在使用4.0.
这需要那么久还是有错误,这是正常的吗?
谢谢你的帮助.
java ×3
javascript ×2
anchor ×1
asp.net ×1
c# ×1
cookies ×1
cryptography ×1
css ×1
dom ×1
filtering ×1
generics ×1
hash ×1
html ×1
html5 ×1
httpcontext ×1
java-ee ×1
mailto ×1
php ×1
preg-match ×1
regex ×1
request ×1
response ×1
sql ×1
type-erasure ×1