小编Jan*_*roň的帖子

当灯箱处于活动状态时,页面停止滚动

我有以下灯箱,其中包括一个表格.一切正常.我唯一的问题是当灯箱处于活动状态时如何使html页面停止滚动.

<a href = "javascript:void(0)" onclick="
  document.getElementById('light').style.display='block';
  document.getElementById('fade').style.display='block'">
<img src="img/add.jpg"/></a></p>
<div id="light" class="white_content">

<input name="degree_1" type="text" size="73"
   value="<?php echo $user_data_profile_education['degree_1'];?>"/>
</br></br>
Grade</br>
<input name="grade_1" type="text" size="73"
   value="<?php echo $user_data_profile_education['grade_1'];?>"/>

<a href = "javascript:void(0)" onclick="
  document.getElementById('light').style.display='none';
  document.getElementById('fade').style.display='none'"> 
</br><img src="img/done_editing.jpg"/> </a></div>
<div id="fade" class="black_overlay"></div>    
Run Code Online (Sandbox Code Playgroud)

这是我的css:

.black_overlay{
    display: none;
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 220%;
    background-color: grey;
    z-index:1001;
    -moz-opacity: 0.8;
    opacity:.80;
    filter: alpha(opacity=80);
}


.white_content {
    display: none;
    position: absolute;
    top: 45%;
    left: 30%;
    width: 32%;
    height: …
Run Code Online (Sandbox Code Playgroud)

html javascript css

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

PHP:implode()传递的参数无效

我正在使用Codeigniter及其验证规则 - 自定义回调验证.无论如何,我认为这似乎与CI无关.

我有这个函数返回一个字符串...

function array_implode($a)
{
  return implode(',', $a);
}
Run Code Online (Sandbox Code Playgroud)

...但我总是得到一条消息implode():传递的参数无效

但是var_dump()告诉我这个:

array(2) {
  [0]=> string(10) "First item"
  [1]=> string(11) "Second item"
}
Run Code Online (Sandbox Code Playgroud)

怎么了?

php arrays implode

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

为什么console.log非法被调用为函数参数?

当我尝试

[1,2,3].forEach(alert);
Run Code Online (Sandbox Code Playgroud)

它会按预期打开数组中每个项目的消息框.

但是,当我尝试

[1,2,3].forEach(console.log);
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

Uncaught TypeError: Illegal invocation
Run Code Online (Sandbox Code Playgroud)

为什么?

javascript google-chrome

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

构造函数中"返回"和"新"的行为

我想知道这两个电话之间的区别是什么:

var a = Array(1,2,3);
var b = new Array(1,2,3);
Run Code Online (Sandbox Code Playgroud)

我试图以这种方式模仿这种行为:

function test() {
  return {x:42};
}

var a = test();
var b = new test();
console.log(a,b); // the same
Run Code Online (Sandbox Code Playgroud)

怎么可能b是这样的a?如果new使用,则应忽略返回值:

function test() {
  return 1;
}

var a = test();
var b = new test();
console.log(a,b); // 1 test{}
Run Code Online (Sandbox Code Playgroud)

javascript object

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

了解模板方法模式

据我所知,Template方法只不过是调用子类中定义的虚方法或抽象方法的普通方法.我是对的,或者我想念这个模式还有其他重要的东西吗?

abstract class Foo {
  public void IamTemplateMethod() { // which will be called in child class object
    method1(); // because this...
    method2(); // ...or this method was called in me
  }
  public virtual void method1() { ... } // to be overriden in child class
  public abstract void method2() { ... } // to be defined in child class
}
Run Code Online (Sandbox Code Playgroud)

如果我是对的,有没有其他常用方法来实现Template方法?

design-patterns template-method-pattern

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

更多设计模式?

我学习了 GoF 设计模式书,并在列表中列出了 Martin Fowler 的 PoEAA 书。(我也有我个人不喜欢的 Judith Bishop 的书。)但是还有更多模式,例如代表团模式。它的起源是什么?这些书中是否还有其他模式没有提到?关于这个主题,还有其他“必读”书籍或在线资源吗?

design-patterns

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

模板类中派生类中的无法访问的成员

这是代码:

template <typename T>
struct Outer {
  struct InnerBase {
    int n;
    InnerBase() : n(42) { }
  };
  struct InnerChild : InnerBase {
    int getN() { return n; }
  };
};
Run Code Online (Sandbox Code Playgroud)

这是问题所在:

In member function 'int Outer<T>::InnerChild::getN()':
error: 'n' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

如果Outer它不是模板,一切正常.怎么会这样?如何在模板中修复它?

c++ templates

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

装饰者模式与Call超级反模式

让我们有一个简单的Decorator示例:

struct IStuff {
  virtual void Info()=0;
  virtual ~IStuff() { }
};

class Ugly : public IStuff {
public:
  void Info() { cout  << "Ugly"; }
};

class Shiny : public IStuff {
  IStuff* stuff;
public:
  Shiny(IStuff* stuff) {
    this->stuff = stuff;
  }
  ~Shiny() {
    delete stuff;
  }
  void Info() {
    stuff->Info(); // <------------------------------- call super?
    cout << "->Shiny";
  }
};

int main() {
  IStuff* s = new Ugly();
  s = new Shiny(s); // decorate
  s = new Shiny(s); // …
Run Code Online (Sandbox Code Playgroud)

c++ design-patterns anti-patterns decorator

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

使用sscanf匹配零个或多个空格

我们有这个代码

char input[] = "key: value";
char key[32], value[32];
sscanf(input, "%31[^:]:%*[ ]%31s", key, value);
Run Code Online (Sandbox Code Playgroud)

之后可以有零个或多个空格:,我想将key ond值存储到c-string变量中.上面的代码可以使用一个或多个空格,但零空格的运气很难.

有一种简单的方法来解析这样的字符串吗?不一定是sscanf,但我想避免使用正则表达式.

编辑

我找到了一个支持已接受答案的参考文献(这是一个有用但非直观的功能):

该函数将读取并忽略在下一个非空白字符之前遇到的任何空白字符(空白字符包括空格,换行符和制表符 - 请参阅isspace).格式字符串中的单个空格验证从流中提取的任何数量的空白字符(包括无).

c string parsing scanf

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

Borland C++ 编译器中的链接 DLL

我使用 freecommandlinetools 编译器 bcc32。我需要在我的程序中使用第三方 dll。我不想调用LoadLibraryand GetProcAddress,而是在我的程序中链接 dll 以直接调用 dll 函数。

#include "somelibrary.h"

int main() {
  somefunction(); // defined in somelibrary.dll
}
Run Code Online (Sandbox Code Playgroud)

我在尝试编译时看到未解析的外部对象。如何说服链接器与 somelibrary.dll 链接?

c dll borland-c++

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