HI,
我试图从javascript(firefox-3.0/Linux)调用flash对象中定义的方法并获得异常:"NPMethod调用非NPObject包装的JSObject".
如果我在window.document.flash_object.func()上使用eval,则会抛出"NPMethod调用非NPObject包装的JSObject".
如果,如果我在页面的侧面定义一个javascript函数,如下所示:
function myFunc(){return flash_object.func();
}
然后做一个window.document.myFunc()的eval工作正常.
我通过一个名为Selenium的测试框架来运行这两个版本.[eval(window.document.flash_object.func())和eval(window.document.myFunc())].
问题似乎是在不传递'this'引用的情况下调用flash-object方法的问题.下面是重现此问题的示例html/js代码:"NPMethod调用非NPObject包装的JSObject".
<script>
function changeColor() {
mymovie.changeColor();
}
function getColorNP() {
var func = mymovie.getColor;
func();
}
</script>
<button type="button" onclick="getColorNP();">getColorNP</button>
<button type="button" onclick="getColor();">getColor</button>
getColorNP throws the exception
Error: NPMethod called on non-NPObject wrapped JSObject!
Source File: http://my.host/Colors/colors.html
getColorNP throws the exception
Error: NPMethod called on non-NPObject wrapped JSObject!
Source File: http://my.host/Colors/colors.html
Run Code Online (Sandbox Code Playgroud)
现在,向javascript专家提问:给定flash对象和方法名称,如何在该对象上调用该方法.可以说,一个函数有两个参数:一个flash对象,一个方法名称为string.我想在该函数内的object.method()上做一个eval.这是可能的,如果可以的话,请你解释一下如何做到这一点.
由于flash对象的方法不是标准的javascript函数,我认为它不可能通过bind()进行绑定.还有其他选择吗?
谢克斯,钱德拉
我正在尝试连接到远程sql数据库,只需在Powershell中运行"select @@ servername"查询.我试图在不使用集成安全性的情况下这样做.我一直在努力使用"get-credential"和"invoke-sqlcmd",但却发现(我认为),你无法将密码从"get-credential"传递给另一个Powershell cmdlet.
这是我正在使用的代码:
add-pssnapin sqlserverprovidersnapin100
add-pssnapin sqlservercmdletsnapin100
# load assemblies
[Reflection.Assembly]::Load("Microsoft.SqlServer.Smo, `
Version=9.0.242.0, Culture=neutral, `
PublicKeyToken=89845dcd8080cc91")
[Reflection.Assembly]::Load("Microsoft.SqlServer.SqlEnum, `
Version=9.0.242.0, Culture=neutral, `
PublicKeyToken=89845dcd8080cc91")
[Reflection.Assembly]::Load("Microsoft.SqlServer.SmoEnum, `
Version=9.0.242.0, Culture=neutral, `
PublicKeyToken=89845dcd8080cc91")
[Reflection.Assembly]::Load("Microsoft.SqlServer.ConnectionInfo, `
Version=9.0.242.0, Culture=neutral, `PublicKeyToken=89845dcd8080cc91")
# connect to SQL Server
$serverName = "HLSQLSRV03"
$server = New-Object -typeName Microsoft.SqlServer.Management.Smo.Server -argumentList $serverName
# login using SQL authentication
$server.ConnectionContext.LoginSecure=$false;
$credential = Get-Credential
$userName = $credential.UserName -replace("\\","")
$pass = $credential.Password
$server.ConnectionContext.set_Login($userName)
$server.ConnectionContext.set_SecurePassword($credential.Password)
$DB = "Master"
invoke-sqlcmd -query "select @@Servername" -database $DB -serverinstance $servername -username …Run Code Online (Sandbox Code Playgroud) 我有一个类,对象作为成员,没有默认的构造函数.我想在构造函数中初始化这个成员,但似乎在C++中我不能这样做.这是班级:
#include <boost/asio.hpp>
#include <boost/array.hpp>
using boost::asio::ip::udp;
template<class T>
class udp_sock
{
public:
udp_sock(std::string host, unsigned short port);
private:
boost::asio::io_service _io_service;
udp::socket _sock;
boost::array<T,256> _buf;
};
template<class T>
udp_sock<T>::udp_sock(std::string host = "localhost",
unsigned short port = 50000)
{
udp::resolver res(_io_service);
udp::resolver::query query(udp::v4(), host, "spec");
udp::endpoint ep = *res.resolve(query);
ep.port(port);
_sock(_io_service, ep);
}
Run Code Online (Sandbox Code Playgroud)
编译器基本上告诉我它找不到udp :: socket的默认构造函数,根据我的研究,我理解C++在调用构造函数之前隐式初始化每个成员.有没有办法以我想要的方式去做,或者它是否"面向Java"并且在C++中不可行?
我通过像这样定义我的构造函数解决了这个问题:
template<class T>
udp_sock<T>::udp_sock(std::string host = "localhost",
unsigned short port = 50000) : _sock(_io_service)
{
udp::resolver res(_io_service);
udp::resolver::query query(udp::v4(), host, "spec");
udp::endpoint ep = *res.resolve(query); …Run Code Online (Sandbox Code Playgroud) 我有以下情况.我有一个验证器来验证我的命令对象,并设置Errors对象上的错误,以便在我的表单中显示.验证器按预期调用并且工作正常,但是当我因验证错误而被发送回我的表单时,我没有显示我在Errors对象上设置的错误.
验证器:
public void validate(Object obj, Errors err) {
MyCommand myCommand = (MyCommand) obj;
int index = 0;
for (Field field : myCommand.getFields()) {
if (field.isChecked()) {
if ((field.getValue() == null) || (field.getValue().equals(""))) {
err.rejectValue("fields[" + index + "].value", "errors.missing");
}
}
index++;
}
if (myCommand.getLimit() < 0) {
err.rejectValue("limit", "errors.invalid");
}
}
Run Code Online (Sandbox Code Playgroud)
命令:
public class MyCommand {
private List<Field> fields;
private int limit;
//getters and setters
}
public class Field {
private boolean checked;
private String name;
private String …Run Code Online (Sandbox Code Playgroud) 我刚刚发现了Sikuli,并希望在没有深入了解在线示例和演示的情况下看到全面的功能列表.
有没有人找到这样的名单?
此外,显然Sikuli也支持更复杂的循环和函数调用,并且似乎基于Python(!!).例子很棒.
谢谢.
非常类似于在C中更改文件中的一个字节,但在Perl中而不是C中.
如何在Perl中打开二进制文件,只更改第一个字节,然后将其写回?
我们正在使用来自提供商的API; 在他们的下一个版本中,他们将提供OpenId服务器,但大多数用户正在使用他们的桌面应用程序.我们正在构建的其他网站将从此应用程序打开,我们应该与openid连接以访问存储在此提供程序中的资源.
如果用户已经使用桌面进行身份验证,我仍然不明白这将如何工作,他们是否必须在其他时间进行身份验证?如果他们关闭浏览器并重新打开它会发生什么,他们是否必须再次执行此操作?
当32位注册表项位于注册表中的Wow6432node时,OpenSubKey()和其他Microsoft.Win32注册表函数是否在64位系统上返回null?
我正在研究一个单元测试框架,它从.NET库调用OpenSubKey().
我的开发系统是安装了Visual Studio 2008 SP1和Windows 7 SDK 的Windows 7 64位环境.
我们单元测试的应用程序是一个32位应用程序,因此注册表是虚拟化的HKLM\Software\Wow6432node.当我们打电话:
Registry.LocalMachine.OpenSubKey( @"Software\MyCompany\MyApp\" );
Run Code Online (Sandbox Code Playgroud)
返回Null,但明确说明在这里工作:
Registry.LocalMachine.OpenSubKey( @"Software\Wow6432node\MyCompany\MyApp\" );
Run Code Online (Sandbox Code Playgroud)
根据我的理解,此功能应该与32位或64位环境无关,应该知道跳转到虚拟节点.
更奇怪的是,在我们的应用程序的编译和安装版本中完全相同的调用在同一系统上正常运行并且正在运行必需的注册表项; 也被放入HKLM\Software\Wow6432node.
我该怎么办?
我有一些hover()JS代码:
$( '.leftMenuProductWrapper').hover (
function () {
},
function () {
});
Run Code Online (Sandbox Code Playgroud)
在第二个函数中,我需要类似的东西:
If ($("#leftMenuWrapper2").hasMouseover){
do this
}else{
do that};
Run Code Online (Sandbox Code Playgroud)
我找不到任何关于如何做的文档.
编辑:
这似乎是一个解决方案:
$('#leftMenuWrapper2').mouseenter(function(){
mouseover = true;
}).mouseleave(function(){
mouseover = false;
});
Run Code Online (Sandbox Code Playgroud)
然后在代码中引用它:
if(mouseover == false){
doSomething
};
Run Code Online (Sandbox Code Playgroud) 我有这个代码,我想做点无关;
(\k t -> chr $ a + flip mod 26 (ord k + ord t -2*a))
我怎么做?
除了"想想这个和某些东西"之外,还有一些关于点自由风格的一般规则吗?
.net ×1
64-bit ×1
binaryfiles ×1
boost ×1
c++ ×1
cmdlets ×1
coding-style ×1
constructor ×1
firefox ×1
flash ×1
function ×1
haskell ×1
java ×1
javascript ×1
jquery ×1
list ×1
mouseover ×1
oop ×1
openid ×1
operations ×1
perl ×1
pointfree ×1
powershell ×1
python ×1
registry ×1
sikuli ×1
spring ×1
spring-mvc ×1
validation ×1