问题列表 - 第28738页

名称中带有" - "的Javascript样式变量无法更改?

好的,所以这个bug花了我很多时间和尴尬.似乎任何带有 - 的名称的样式变量都不能被javascript修改.

如下所示:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Class Test</title>
        <meta charset="utf-8" />
        <style>
            body { text-align: center; background-color: #ffffff;}
            #box { position: absolute; left: 610px; top: 80px; height: 50px; width: 50px; background-color: #ff0000; color: #000000;}
        </style>

        <script type="text/javascript">
            var box = 0;
        </script>
    </head>

    <body>
        <div id="box" ></div> 
        <script type="text/javascript">
            box = document.getElementById('box');
            box.style.background-color = "#0000ff";
        </script>

    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

所述示例中的框将保持红色.

那么如何用 - 的名字改变一个样式变量呢?

javascript

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

如何在JSON中转义反斜杠?

我使用Firefox的本机JSON.parse()来解析一些包含正则表达式作为值的JSON字符串,例如:

var test = JSON.parse('{"regex":"/\\d+/"}');
Run Code Online (Sandbox Code Playgroud)

上面的'\ d'引发了JSON.parse()的异常,但是当我使用eval(这是我试图避免的)时工作正常.

我想要的是保留正则表达式中的'\' - 是否有一些其他JSON友好的方法来逃避它?

javascript firefox json

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

停用或删除HTML上的滚动条

我想scrollbar在HTML页面中取消激活或删除垂直.
怎么做 ?

谢谢.

html css scrollbar

23
推荐指数
2
解决办法
11万
查看次数

javascript forEach方法有什么用(地图不能做)?

我在map和foreach中看到的唯一区别map是返回一个数组而forEach不是.但是,我甚至不理解方法的最后一行forEach" func.call(scope, this[i], i, this);".例如,是不是" this"和" scope"指的是同一个对象而不是this[i]并且i指的是循环中的当前值?

我在另一篇文章中注意到有人说" forEach当你想根据列表的每个元素做某事时使用.例如,你可能会在页面上添加内容.基本上,它非常适合你想要的"副作用".我不知道副作用是什么意思.

Array.prototype.map = function(fnc) {
    var a = new Array(this.length);
    for (var i = 0; i < this.length; i++) {
        a[i] = fnc(this[i]);
    }
    return a;
}

Array.prototype.forEach = function(func, scope) { 
    scope = scope || this; 
    for (var i = 0, l = this.length; i < l; i++) {
        func.call(scope, this[i], i, this); 
    } 
}
Run Code Online (Sandbox Code Playgroud)

最后,这些方法在javascript中是否有任何实际用途(因为我们不更新数据库),除了操纵这样的数字:

alert([1,2,3,4].map(function(x){ …
Run Code Online (Sandbox Code Playgroud)

javascript arrays foreach dictionary prototype

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

如何在给定数字的左侧放置零到最多6位数,包括给定的数字

我有这种方法接收ID号并根据该ID下载HTML网站.

通常,IMDB链接是这样的:

http://www.imdb.com/title/tt0892791/
http://www.imdb.com/title/tt1226229/
http://www.imdb.com/title/tt0000429/
Run Code Online (Sandbox Code Playgroud)

它们都跟随'tt'然后是7位数,缺少数字变成零以填充左侧空格.

我怎样才能用C#实现这个目标?我有点难过.

这是我的方法:

/// <summary>
/// Find a movie page using its precise IMDB id.
/// </summary>
/// <param name="id">IMDB Movie ID</param>
/// <returns>Returns an HtmlDocument with the source code included.</returns>
public HtmlDocument ByID(string id)
{
    string url = String.Format("http://www.imdb.com/title/tt{0}/", id);            
    HtmlDocument page = downloader.Load(url);
    return page;
}
Run Code Online (Sandbox Code Playgroud)

非常感谢你的时间,如果你有兴趣帮忙,你可以在这里查看TheFreeIMDB的完整源代码:http://thefreeimdb.codeplex.com/

.net c# string

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

如何检查在C#中是否未选择ListBox的选定值?

此代码将显示列表框中的选定值.例如,如果我选择第1项,我将得到以下输出:您已选择第1项.

Label1.Text = "You have selected " + DropDownList1.SelectedValue + "<br />";
Run Code Online (Sandbox Code Playgroud)

但如果我没有选择任何内容并单击"提交"按钮,我会得到:您已选择

我需要做什么才能显示"你没有选择任何东西.请选择至少1个项目."

更新:我正在使用ASP.NET WebForms.

c# asp.net validation drop-down-menu

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

选项卡异常消息

06-14 00:21:30.398:ERROR/AndroidRuntime(332):引起:java.lang.RuntimeException:您的内容必须有一个TabHost,其id属性为'android.R.id.tabhost'

这是什么意思?我已经给了tabhost的id.我可以在R.java中看到id.

这是.xml:

<TabHost
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

        <TabWidget
            android:id="@+id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@+id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)

android

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

在Web根目录之外存储脚本文件

为了保护带有敏感信息的php文件(如数据库连接和登录信息)的具体原因,我已经看到建议将部分或全部php包含文件存储在Web文档根目录(我的情况下为username/public_html)之外的某些地方.如果Web服务器打嗝并停止保护php文件,那么它们对于知道在哪里看的外人来说是"可见的".

对我来说这似乎有点偏执,但我猜这些人之前已经被严重烧伤所以我愿意继续这样做.该建议通常采用包含文件的形式,例如"../include_files/",因此它不直接在文档根目录中,也不能通过Web服务器直接访问外部人员.

我的问题是:这种方式之间的安全性存在显着差异,只是将"include_files"目录放在文档根目录下并在其中粘贴.htaccess文件(带有相应的条目)?将.htaccess文件放在'../include_files/'中会有什么重大改进吗?

TIA,

蒙特

php .htaccess

9
推荐指数
2
解决办法
8909
查看次数

关于存储过程的访谈问题

你不会在存储过程中存储什么样的东西?

sql

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

C++"if then else"模板替换

我想声明一个模板如下:

template <typename T>
{ 
  if objects of class T have method foo(), then 
   const int k=1
  else 
   if class has a static const int L then
    const int k=L
   else 
    const int k=0;


}
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?一般来说,我想要一种基于T(或T中定义的typedef)属性设置静态consts的机制.

c++ templates if-statement

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