小编Pea*_*key的帖子

如果我不在Javascript函数中传递参数会发生什么?

我是新来的Javascript的世界里,有写非常基本的功能,修补和在下面的例子中被偶然事故,我不能确定为什么它的时候我不传递参数时,功能需求它的工作原理.

样本功能

function myfunction(x) {
    alert("This is a sample alert");
}
Run Code Online (Sandbox Code Playgroud)

现在,如果我调用该函数,myfunction();我将收到警报.为什么我没有传递参数时能够在没有任何错误或警告的情况下调用该函数?

编辑

我没想到这么多伟大的答案,我绝不在一个位置,但能说哪个答案是最好的所以我只能对请求人提出最好的答案,我会奖励接受该人.

javascript overloading

76
推荐指数
4
解决办法
5万
查看次数

无效的对象名称SQL Server 2008 R2 - 存储过程

我试图用命令改变现有的存储过程

ALTER'name_of_stored"程序'

但是,该名称以红色突出显示,表示它是无效对象.我能够成功执行该命令但是我想知道为什么SQL Server 2008 R2会将其记录为错误.在此输入图像描述

sql-server-2008

38
推荐指数
3
解决办法
5万
查看次数

建议的HTML 5元标记应该被认为是必须的

我正在寻找将用XHTML 1.0编写的页面迁移到HTML 5,并且meta<head>元素中包含标记时正在考虑最低要求.例如,我当前符合XHTML 1.0的页面具有以下meta标记

<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta http-equiv="content-language" content="en-us" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="copyright" content="&copy; 2012" />
<meta name="robot" content="noindex, nofollow" />
Run Code Online (Sandbox Code Playgroud)

以下内容对于HTML 5是否足够,我还可以包含它们吗?

我的理解是,meta元素<meta http-equiv="content-language" content="en-us" />现在可以全局应用于 <html>元素.

<html lang="en-us">
<head>
<meta charset="UTF-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="keywords" content="" />
<meta name="description" …
Run Code Online (Sandbox Code Playgroud)

html html5

35
推荐指数
3
解决办法
5万
查看次数

为什么Microsoft Outlook在发送HTML电子邮件时不尊重列表样式?

我有以下代码,对于我的生活,我不能让它在Microsoft Outlook中工作.

<ul style="margin-left: 50px; line-height: 50px; list-style: none;">
    <li style="font-size: 1.5em; list-style: none;">[UniqueCode]</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

还有另一种方法可以达到相同的效果吗?我正在尝试向一群人发送HTML电子邮件.

html css outlook

25
推荐指数
1
解决办法
4万
查看次数

PHP未定义索引:HTTP_USER_AGENT

以下代码验证访问该站点的用户代理,但是我收到错误.我需要更新哪些内容以适应没有设置用户代理的情况?

错误 PHP注意:未定义的索引:第7行的Utils.php中的HTTP_USER_AGENT

public static function detectBrowser()
    {
        $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);

        if (preg_match('/opera/', $userAgent)) {
            $name = 'opera';
        }
        elseif (preg_match('/webkit/', $userAgent)) {
            $name = 'safari';
        }
        elseif (preg_match('/msie/', $userAgent)) {
            $name = 'msie';
        }
        elseif (preg_match('/mozilla/', $userAgent) && !preg_match('/compatible/', $userAgent)) {
            $name = 'mozilla';
        }
        else {
            $name = 'unrecognized';
        }

        if (preg_match('/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/', $userAgent, $matches)) {
            $version = $matches[1];
        }
        else {
            $version = 'unknown';
        }

        if (preg_match('/linux/', $userAgent)) {
            $platform = 'linux';
        }
        elseif (preg_match('/macintosh|mac os …
Run Code Online (Sandbox Code Playgroud)

php user-agent

19
推荐指数
2
解决办法
4万
查看次数

从Python搜索模块路径中删除路径

我明白sys.path指的是

  1. 具有系统库的OS路径.我认为这些是/lib在*nix或WindowsWindows上引用的.
  2. 当前目录python从 - 我接受如果Python启动C:\Python,这将是当前路径
  3. 环境变量$ PYTHONPATH或%PYTHONPATH% - 这是指我可以从命令行调用Python二进制文件的路径
  4. 你可以在运行时添加路径 - 我在运行IDLE时理解这一点

我能够通过运行命令添加路径,sys.path.append但是当我运行命令sys.path.remove"删除"我追加的路径时,我无法这样做.有没有办法这样做而不必每次关闭IDLE?

我在Windows 7和Ubuntu上运行Python 2.7

python-2.7

17
推荐指数
1
解决办法
7万
查看次数

Is there a parent child relationship between absolute and relative positioning in CSS?

I am new to the world of coding as well as CSS. Having read a number of articles regarding relative and absolute positioning, my understanding is as follows. However, I am unsure if an absolute position should be the child of a parent relative position or vice versa.

  • There are 4 position properties, that is, static, relative, absolute and fixed.
  • If an element has a relative position it is still part of the normal flow of the document. However, …

html css

15
推荐指数
2
解决办法
6120
查看次数

使用正则表达式时\ b如何工作?

如果我有一个句子并希望在特定单词之前匹配之后显示一个单词或所有单词,例如我想显示单词fox后面brown The quick brown fox jumps over the lazy dog,我知道我可以看起来正面看后面(?<=brown\s)(\w+)但是我不喜欢我完全理解在实例中使用\ b (?<=\bbrown\s)(\w+).我使用http://gskinner.com/RegExr/作为我的测试人员.

regex

14
推荐指数
2
解决办法
1万
查看次数

javascript函数中是否允许相同的变量和参数名称?

作为一个例子,我允许使用相同的变量和参数?我可以遇到什么问题?

示例代码

function mytask(name,title){
            var name = name;
            var title = title;
            var showalert = ("Hi " + name + " your job title is " + title);
            console.log(showalert);
            return showalert;
        }

document.write(mytask("dan", "administrator"));
Run Code Online (Sandbox Code Playgroud)

javascript

14
推荐指数
1
解决办法
8595
查看次数

PHP清理数据

我是编码和PHP的新手,因此我想了解清理表单数据的最佳方法是什么,以避免格式错误的页面,代码注入等.我在下面找到的示例脚本是一个很好的例子吗?

代码最初发布于http://codeassembly.com/How-to-sanitize-your-php-input/

/**
 * Sanitize only one variable .
 * Returns the variable sanitized according to the desired type or true/false 
 * for certain data types if the variable does not correspond to the given data type.
 * 
 * NOTE: True/False is returned only for telephone, pin, id_card data types
 *
 * @param mixed The variable itself
 * @param string A string containing the desired variable type
 * @return The sanitized variable or true/false
 */

function sanitizeOne($var, $type)
{ …
Run Code Online (Sandbox Code Playgroud)

php sanitize

13
推荐指数
3
解决办法
4万
查看次数