我正在用HTML5和Javascript制作游戏.
我怎么能通过Javascript播放游戏音频?
我正在尝试加载本地JSON文件,但它无法正常工作.这是我的JavaScript代码(使用jQuery:
var json = $.getJSON("test.json");
var data = eval("(" +json.responseText + ")");
document.write(data["a"]);
Run Code Online (Sandbox Code Playgroud)
test.json文件:
{"a" : "b", "c" : "d"}
Run Code Online (Sandbox Code Playgroud)
没有显示任何内容,Firebug告诉我数据未定义.在Firebug中,我可以看到json.responseText并且它是好的和有效的,但是当我复制该行时很奇怪:
var data = eval("(" +json.responseText + ")");
Run Code Online (Sandbox Code Playgroud)
在Firebug的控制台中,它可以工作,我可以访问数据.
有人有解决方案吗?
我有一段很大的文字,分为以下的分段<br>:
<p>
Blah blah blah.
<br/>
Blah blah blah. Blah blah blah. Blah blah blah.
<br/>
Blah blah blah.
</p>
Run Code Online (Sandbox Code Playgroud)
我想扩大这些分段之间的差距,就像有两个<br>或类似的东西.我知道正确的方法是使用<p></p>,但是现在我无法改变这种布局,所以我正在寻找仅限CSS的解决方案.
我试过设置<br>的line-height和height有display: block,我也一派,堆栈溢出-ED简单,但没有找到任何解决方案.这是否可以在不改变布局的情况下实现?
我有两个变量:
site1 = "www.somesite.com";
site2 = "www.somesite.com/";
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情
function someFunction(site)
{
// If the var has a trailing slash (like site2),
// remove it and return the site without the trailing slash
return no_trailing_slash_url;
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
做InitializeComponent()什么,以及它在WPF中如何运作?
首先,我会特别感兴趣的是了解构造顺序的血腥细节,以及附加属性时会发生什么.
软删除是个好主意还是坏主意?
您只需将其标记为IsDeleted = true,而不是实际删除数据库中的记录,并且在恢复记录后,您可以将其标记为False.
这是一个好主意吗?
最好是物理删除记录,然后将其移动到存档数据库,如果用户想要记录回来,那么软件会在存档中查找记录并重新创建它吗?
我需要生成一个作为控制台应用程序的子进程,并捕获其输出.
我为方法编写了以下代码:
string retMessage = String.Empty;
ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = command;
startInfo.FileName = exec;
p.StartInfo = startInfo;
p.Start();
p.OutputDataReceived += new DataReceivedEventHandler
(
delegate(object sender, DataReceivedEventArgs e)
{
using (StreamReader output = p.StandardOutput)
{
retMessage = output.ReadToEnd();
}
}
);
p.WaitForExit();
return retMessage;
Run Code Online (Sandbox Code Playgroud)
但是,这不会返回任何内容.我不相信该OutputDataReceived事件被回调,或者该WaitForExit()命令可能阻塞该线程,因此它永远不会回调.
有什么建议?
编辑:看起来我在回调中努力了.这样做:
return p.StandardOutput.ReadToEnd();
Run Code Online (Sandbox Code Playgroud)
似乎工作正常.
在.NET 3.5中似乎没有OrderedDictionary(在System.Collections.Specialized命名空间中)的通用实现.有没有我错过的?
我发现那里的实现提供了功能,但想知道是否/为什么没有开箱即用的通用实现,如果有人知道它是否是.NET 4.0中的东西?