小编Mar*_*all的帖子

禁用ALT + F4,是的,我知道不建议这样做

我需要一个JavaScript脚本,禁止用户使用ALT + F4关闭.我到处都看,但只是每个人都说不建议.

甚至可能不可能,如果不是,我将只需要检测用户何时退出并将其记录在数据库中.

这是我当前的脚本,它检测用户是否按下ALT或F4,但我无法取消该按键.有没有办法让浏览器认为用户按下了另一个键,所以组合将是ALT + G + F4,这会破坏ALT + F4组合?

//Run on keydown, disable user from quiting via ALT+F4
document.onkeydown = function(evt) {
    evt = evt || window.event;
    //Get key unicode
    var unicode = evt.keyCode ? evt.keyCode : evt.charCode;

    //Check it it's ALT or F4 (115)
    if (unicode == 115 || evt.altKey == 1)
    {
        window.event.cancelBubble = true;
        window.event.returnValue = false;
    }
};
Run Code Online (Sandbox Code Playgroud)

javascript

0
推荐指数
2
解决办法
5649
查看次数

JavaScript中的setTimeout不起作用

奇怪的问题在这里,我不明白为什么它不起作用.但基本上按下按钮时警报就会响起,根本没有5秒延迟!

<html>
<head>
    <title>Testing Page</title>
</head>
<script type="text/javascript">
function testing() {
    var delay = 5000;
    setTimeout(alert("5 seconds later..."),delay);  
}
</script>
<body>
<input type="button" value="Run Function" onClick="testing()">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html javascript delay

0
推荐指数
2
解决办法
212
查看次数

单击标签内的按钮时不要选中复选框

我有以下设置(简化),在标签内我有一些图像,它们激活 JavaScript 功能,如果用户单击这些图像之一,是否有办法忽略标签上的单击?

<input type="checkbox" id="i_87" name="image[]" />
<label for="i_87" style="width:500px;height:500px;background-image:url('image.jpg');">
    <img src="bt1.jpg" onClick="somefun1()" />
    <img src="bt2.jpg" onClick="somefun2()" />
</label>
Run Code Online (Sandbox Code Playgroud)

只是为了澄清,我不希望它在单击图像时选中复选框,但是在单击其他任何地方时它应该选中复选框!

html javascript

0
推荐指数
1
解决办法
2420
查看次数

将对象添加到列表,无法分配给Add,因为它是一个组方法

目前使用以下代码收到错误,我不知道如何修复它!

这是错误: Cannot assign to 'Add' because it is a 'method group'

这是我的App.xaml.cs:

public partial class App : Application
{
    //Public list of users and form can access
    List<User> LoggedUsers = new List<User>();

    //First startup of the application
    public void Application_Startup(object sender, StartupEventArgs e)
    {
        //First startup, display the login form
        LoginWindow FirstLogin = new LoginWindow();
        FirstLogin.ShowDialog();

        //If the login form was closed properly, handle the user
        if (FirstLogin.DialogResult == true)
        {
            //Add the user to the list of logged …
Run Code Online (Sandbox Code Playgroud)

c# wpf

0
推荐指数
1
解决办法
379
查看次数

找不到元素的孩子

由于某种原因,我无法从div的类名中获取孩子.slideshow-dots.这是与它的孩子的div:

<div class="slideshow-dots">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
Run Code Online (Sandbox Code Playgroud)

这是错误:

未捕获的TypeError:无法读取未定义的属性"className"

下面是我的代码,我也无法调用公共方法showSlides.

(function($) {
    $.fn.MarvSimpleGallery = function( options ) {
      var instance = this;
      instance.index = 1;

      var settings = $.extend({
        // These are the defaults.
        arrows: true,
        dots: true,
        numbers: true
      }, options );

      var init = function() {
        instance.dotCont = instance.find('.slideshow-dots')[0];
        instance.slides = instance.find('.mySlides');

        // Assign event listeners
        instance.find('.prev').click(function() { instance.showSlides(instance.index += -1); });
        instance.find('.next').click(function() { instance.showSlides(instance.index += 1); });

        // …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

0
推荐指数
1
解决办法
72
查看次数

Vue 内联点击事件`this` 未定义

我在下面的代码中收到一个错误,说this未定义。

<div class="location-list__item" v-for="(value, key) in locations.data">
    <div class="location-list__item--text"
         :class="{ selected: selected === key }"
         @click="() => { this.selected = key; this.manageSurrounding = false }">
        <i class="fas fa-compass"></i> {{ value.name }}
        <span v-if="value.changed" class="has-text-danger"> Changed</span>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

但是,如果我更改此行:

@click="() => { this.selected = key; this.manageSurrounding = false }"

对此

@click="selected = key"

它工作正常,但是我需要同时更改manageSurrounding并且我不想为这么简单的事情创建一个方法。

vue.js

0
推荐指数
1
解决办法
61
查看次数

PHP停止1行代码的警告

我有以下应该存在的警告,但是有没有办法在不实际禁用警告的情况下阻止它们写到页面?

警告:

警告:file_get_contents(E:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(F:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(G:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(H:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(I:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(J:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(K:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(L:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(M:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa \ test.php中没有此类文件或目录

警告:file_get_contents(N:/connected.txt):无法打开流:第19行的C:\ xampp \ htdocs \ ppa …

php error-handling

-1
推荐指数
1
解决办法
625
查看次数

无法从静态方法更改但需要使用方法来设置非静态属性

我有一个静态的方法,我不能使它非静态,但是我需要使用这个方法设置一个非静态属性,但是我不能因为它是静态的,建议?

//Update property with current availability
        private static void ReportAvailability()
        {
            if (NetworkStatus.IsAvailable)
            {
                Conn = true;
            }
            else
            {
                Conn = false;
            }
        }

        private bool _conn;
        public bool Conn
        {
            get { return _conn; }
            set
            {
                if (_conn != value)
                    _conn = value; RaisePropertyChanged();
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# wpf

-1
推荐指数
1
解决办法
50
查看次数

ASP.NET代码无法运行,收到错误:无法找到资源

我有以下代码,我希望只在我的浏览器中加载页面,用IIS 7运行它.

<%@ Page Language="C#" Debug="true" %>
<%
using System;

protected string callRotate()
{
    ProcessStartInfo info = new ProcessStartInfo();
    string[] arguments = { "arg1" , "arg2" };
    info.FileName = "ConsoleApplication1";

    Process process = Process.Start(info.FileName, arguments);
    Process.Start(info);
}
%>
Run Code Online (Sandbox Code Playgroud)

这是我在浏览器中遇到的错误:

    Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1513: } expected …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

-2
推荐指数
1
解决办法
1111
查看次数

标签 统计

javascript ×4

c# ×3

html ×2

wpf ×2

asp.net ×1

delay ×1

error-handling ×1

jquery ×1

php ×1

vue.js ×1