我想写一个网页进行在线测验.我的基本要求是,如果参加测验的人改变标签或打开新窗口,即使没有最小化浏览器,即如果该人试图从其他窗口/标签看到答案,测验应该停下来.我怎么能这样做?
PS:它不应该是一些非常新的HTML5功能.我希望目前所有主流浏览器都支持它.
我知道这不是 toastr(或一般的 toast 通知)的用途,但我想将它们用作modal notification. 我的想法如下。
在吐司秀上:
toastr.options.onShown = function() { //Create an overlay on the entire page}
Run Code Online (Sandbox Code Playgroud)
覆盖:
#overlay {
background-color: rgba(0, 0, 0, 0.8);
z-index: 999;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: none;
}
Run Code Online (Sandbox Code Playgroud)
并在吐司关闭:
toastr.options.onHidden = function() { //make overlay go away }
Run Code Online (Sandbox Code Playgroud)
另外,我将 toast 的超时设置为 0,这样它就不会自行消失。
问题:我希望 Toast 通知保持在覆盖层之上而不是在其后面,因为覆盖层将覆盖所有内容。我该怎么做?
我在C#代码中进行了很多Web API调用。我不知道如何捕捉错误。假设互联网连接无法正常工作,那么我的代码显示了运行时错误。我如何正确地将它们放入try catch块,一般规则是什么。我发现的所有文章都是关于如何抛出错误和错误消息的。
示例API调用:
WebResponse webResponse = webRequest.GetResponse();
string res = webResponse.ToString();
Run Code Online (Sandbox Code Playgroud)
也
using (var client = new HttpClient())
client.BaseAddress = new Uri(CairoBaseUrl);
var getStringTask = client.GetStringAsync(requestUrl);
response = await getStringTask;
Run Code Online (Sandbox Code Playgroud)
和,
HttpResponseMessage response = await client.PostAsync(
url,requestContent);
Run Code Online (Sandbox Code Playgroud) 我想在我的ASP.NET MVC 2应用程序中显示自定义403页面.我按照以下链接.我在配置文件中添加了以下内容:
<httpErrors>
<remove statusCode="403" subStatusCode="-1"/>
<error statusCode="403" path="/403.htm" responseMode="ExecuteURL"/>
</httpErrors>
Run Code Online (Sandbox Code Playgroud)
我仍然看到默认的ASP.NET 403错误页面.怎么了?

我想匹配和查找被空格或特殊字符包围的单词索引。例如:
To find: test
this is input test : True
this is#input_ : True
this isinput : False
thisisinputtest: False
this @test is right: True.
Run Code Online (Sandbox Code Playgroud)
我如何匹配它并找到索引。我当前的正则表达式失败:(?i)[^a-zA-Z0-9]test[^a-zA-Z0-9]
我有一个暴露接口的DLL,看起来像这样:
public Interface IClientGroup
{
IQueryable ClientsGroup {get;}
void Activate(ClientGroup clientgroup);
//many other members and functions
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器类中,它在构造函数中传递,如下所示:
public ControllerClass(IClientGroup clientgroup)
{
var _clientgroup = clientgroup
}
//later _clientgroup used to access everything in Interface
Run Code Online (Sandbox Code Playgroud)
现在,当我调试时,我看到它被传递给了构造函数,这些值已经初始化了,所以我假设我可以简单地传入IClientgroup clientgroup任何函数并且它已经被初始化但是它是null,每次如果我在使用之前声明它并且说it is type but used as variable如果我diectly传递给函数在consturctor完成.
public UseValues(IclientGroup clientgroup)
{
//error: IClientGroup is type but used as variable
}
Run Code Online (Sandbox Code Playgroud)
如何在初始化值的情况下使用客户端组?我无法从dll中看到确切的实现.
我在vm上安装了Python Social Auth,并尝试运行makemigrations并收到此错误:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/myenv/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 338, in execute_from_command_line
utility.execute()
File "/opt/myenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312,
in execute
django.setup()
File "/opt/myenv/local/lib/python2.7/site-packages/django/__init__.py",
line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/opt/myenv/local/lib/python2.7/site-packages/django/apps/registry.py", line 85,
in populate
app_config = AppConfig.create(entry)
File "/opt/myenv/local/lib/python2.7/site-packages/django/apps/config.py",
line 127, in create
"'%s' isn't a subclass of AppConfig." % entry)
django.core.exceptions.ImproperlyConfigured: 'social.apps.django_app.middleware.SocialAuthExceptionMiddleware'
isn't a subclass of AppConfig.
Run Code Online (Sandbox Code Playgroud)
我在本地主机上运行了相同的应用程序,并且运行正常。我不明白此错误的含义。请帮忙。
我试图了解 ScheduledExecutorService 是如何工作的。我写了这个简单的测试:
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(10);
executorService.scheduleAtFixedRate(() -> {
try {
System.out.println("Test " + Thread.currentThread().getId());
Thread.sleep(10000);
System.out.println("End " + Thread.currentThread().getId());
} catch (Exception ex) {
}
}, 0, 100, TimeUnit.MILLISECONDS);
Run Code Online (Sandbox Code Playgroud)
我看到控制台上打印了以下内容:
Test 19
End 19
Test 19
End 19
Test 21
End 21
Run Code Online (Sandbox Code Playgroud)
等等。执行器不应该在第一个线程结束之前安排并启动一个新线程吗?如果核心池大小为 10,为什么线程一个接一个启动。不应该 10 个线程一起运行。
总新手在这里.我正在为我的主页创建自定义注册表单.我做了以下事情:
Run Code Online (Sandbox Code Playgroud)class RegForm(forms.Form): email = forms.EmailField() password=forms.PasswordInput() password2=forms.PasswordInput() phone= forms.CharField(max_length=10)
<div class="form-group">
{{ form.email.errors }}
<label for="{{form.email.id_for_label}}">
<b>Email</b>
</label>
{{ form.email }}
</div>
<div class="form-group">
{{ form.non_field_errors }}
<label for="{{ form.password.id_for_label }}">
<b>Password</b>
</label>
{{ form.password }}
</div>
<div class="form-group">
{{ form.non_field_errors }}
<label for="register_password2">
<b>Re-enter Password</b>
</label>
{{ form.password2 }}
</div>
<div class="form-group">
{{ form.non_field_errors }}
<label for="phone">
<b>Phone Number</b>
</label>
{{ form.phone }}
</div>Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)def register(request): registered = False if request.method == 'POST': form = …