问题:

我尝试将node-vlc与nw.js(v0.12.0-alpha2)一起使用。 当我启动我的应用程序没有nw.js它工作,但当我用nw.js启动它时,我收到一个错误:

未捕获的错误:模块没有自行注册。“,来源:/home/alexis/Bureau/dev/jukebox/node_modules/vlc/node_modules/ffi/node_modules/bindings/bindings.js(84)

我用nw-gyp尝试了一些命令,但它无法帮助我。 我在Ubuntu 14,64位。

I try to use node-vlc with nw.js (v0.12.0-alpha2).When i launch my app without nw.js it works, but when i launch it with nw.js i got an error:Uncaught Error: Module did not self-register.”, source: /home/alexis/Bureau/dev/jukebox/node_modules/vlc/node_modules/ffi/node_modules/bindings/bindings.js (84)I tried some commands with nw-gyp but it couldn’t help me.I am on Ubuntu 14, 64-bit.

问题:

我有一个项目,我需要使用JavaScript创建一个<iframe>元素并将其附加到DOM。 之后,我需要在<iframe>中插入一些内容。 它是一个嵌入第三方网站的小部件。

我没有设置<iframe>的“src”属性,因为我不想加载页面; 相反,它用于隔离/沙箱插入我插入的内容,以便我不会遇到CSS或JavaScript与父页面冲突。 我正在使用JSONP从服务器加载一些HTML内容并将其插入此<iframe>。

我有这个工作正常,有一个严重的例外 – 如果在父页面中设置document.domain属性(它可能在部署此小部件的某些环境中),Internet Explorer(可能是所有版本,但我已经当我尝试访问我创建的<iframe>的文档对象时,在6,7和8中确认给了我“访问被拒绝”错误。 它不会在我测试的任何其他浏览器中发生(所有主要的现代浏览器)。

这是有道理的,因为我知道Internet Explorer要求您将所有窗口/框架的document.domain设置为相互通信到相同的值。 但是,我不知道有任何方法可以在我无法访问的文档上设置此值。

是否有人知道这样做的方法 – 以某种方式设置此动态创建的<iframe>的document.domain属性? 或者我不是从正确的角度看待它 – 有没有另一种方法可以实现我的目标而不会遇到这个问题? 我确实需要在任何情况下使用<iframe>,因为隔离/沙盒窗口对于此小部件的功能至关重要。

这是我的测试代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Document.domain Test</title>
    <script type="text/javascript">
      document.domain = 'onespot.com'; // set the page's document.domain
    </script>
  </head>
  <body>
    <p>This is a paragraph above the &lt;iframe&gt;.</p>
    <div id="placeholder"></div>
    <p>This is a paragraph below the &lt;iframe&gt;.</p>
    <script type="text/javascript">
      var iframe = document.createElement('iframe'), doc; // create <iframe> element
      document.getElementById('placeholder').appendChild(iframe); // append <iframe> element to the placeholder element
      setTimeout(function() { // set a timeout to give browsers a chance to recognize the <iframe>
        doc = iframe.contentWindow || iframe.contentDocument; // get a handle on the <iframe> document
        alert(doc);
        if (doc.document) { // HEREIN LIES THE PROBLEM
          doc = doc.document;
        }
        doc.body.innerHTML = '<h1>Hello!</h1>'; // add an element
      }, 10);
    </script>
  </body>
</html>

我托管了它:

http://troy.onespot.com/static/access_denied.html

你会看到你是否在IE中加载这个页面,在我调用alert()时,我确实有一个句柄来处理<iframe>的窗口对象; 我只是无法深入到其文档对象中。

非常感谢任何帮助或建议! 我非常感谢能帮助我找到解决方案的人。

I have project in which I need to create an <iframe> element using JavaScript and append it to the DOM.After that, I need to insert some content into the <iframe>.It’s a widget that will be embedded in third-party websites.I don’t set the “src” attribute of the <iframe> since I don’t want to load a page;rather, it is used to isolate/sandbox the content that I insert into it so that I don’t run into CSS or JavaScript conflicts with the parent page.I’m using JSONP to load some HTML content from a server and insert it in this <iframe>.I have this working fine, with one serious exception – if the document.domain property is set in the parent page (which it may be in certain environments in which this widget is deployed), Internet Explorer (probably all versions, but I’ve confirmed in 6, 7, and 8) gives me an “Access is denied” error when I try to access the document object of this <iframe> I’ve created.It doesn’t happen in any other browsers I’ve tested in (all major modern ones).This makes some sense, since I’m aware that Internet Explorer requires you to set the document.domain of all windows/frames that will communicate with each other to the same value.However, I’m not aware of any way to set this value on a document that I can’t access.Is anyone aware of a way to do this – somehow set the document.domain property of this dynamically created <iframe>?Or am I not looking at it from the right angle – is there another way to achieve what I’m going for without running into this problem?I do need to use an <iframe> in any case, as the isolated/sandboxed window is crucial to the functionality of this widget.Here’s my test code:I’ve hosted it at:http://troy.onespot.com/static/access_denied.htmlAs you’ll see if you load this page in IE, at the point that I call alert(), I do have a handle on the window object of the <iframe>;I just can’t get any deeper, into its document object.Thanks very much for any help or suggestions!I’ll be indebted to whomever can help me find a solution to this.

问题:

每当我在终端中运行webpack时,我得到:

Hash: efea76b1048c3a97b963
Version: webpack 1.12.13
Time: 33ms
    + 1 hidden modules

ERROR in Cannot find module 'babel-core'

这是我的webpack.config.js文件

module.exports = {
  entry: './app-client.js',
  output: {
    filename: 'public/bundle.js'
  },
  module: {
    loaders: [
      {
        exclude: /(node_modules|app-server.js)/,
        loader: 'babel'
      }
    ]
  }
}

的package.json

{
  "name": "react",
  "version": "1.0.0",
  "description": "React polling app",
  "main": "app-client.js",
  "dependencies": {
    "babel-loader": "^6.2.2",
    "bootstrap": "^3.3.6",
    "express": "^4.13.4",
    "react": "^0.14.7"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Whenever I run webpack in the terminal I get:Here is my webpack.config.js filepackage.json

问题:

我有一些Javascript JQuery代码每隔5分钟对服务器进行一次Ajax调用,这是为了保持服务器会话的存活并保持用户登录。我在JQuery中使用$.ajax()方法。 这个函数似乎有一个’错误’属性,我试图在用户的互联网连接断开时使用,以便KeepAlive脚本继续运行。 我正在使用以下代码:

var keepAliveTimeout = 1000 * 10;

function keepSessionAlive()
{
    $.ajax(
    {
        type: 'GET',
        url: 'http://www.mywebapp.com/keepAlive',
        success: function(data)
        {
            alert('Success');

            setTimeout(function()
            {
                keepSessionAlive();
            }, keepAliveTimeout);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown)
        {
            alert('Failure');

            setTimeout(function()
            {
                keepSessionAlive();
            }, keepAliveTimeout);
        }
    });
}

当我运行它时,我会在屏幕上每10秒钟在一个警告框中弹出“成功”,这很好。 但是,一旦我拔下网线,我就什么也得不到,我期待错误功能被调用并看到“故障”警告框,但没有任何反应。

假设’错误’功能仅适用于从服务器返回的非’200’状态代码,我是否正确? 有没有办法在进行Ajax调用时检测网络连接问题?

I have some Javascript JQuery code that does an Ajax call to the server every 5 mins, it’s to keep the server session alive and keep the user logged in. I’m using $.ajax() method in JQuery.This function seems to have an ‘error’ property that I’m trying to use in the event that the user’s internet connection goes down so that the KeepAlive script continues to run.I’m using the following code:When I run it, I’ll get ‘Success’ popup on the screen in an alert box every 10 seconds which is fine.However, as soon as I unplug the network cable, I get nothing, I was expecting the error function to get called and see a ‘Failure’ alert box, but nothing happens.Am I correct in assuming that the ‘error’ function is only for non ‘200’ status codes returned from the server?Is there a way to detect network connection problems when making an Ajax call?

问题:

一些用户在我的网站上偶尔报告JS错误。 错误消息显示“期望的标识符,字符串或数字”,并且行号为423725915,这只是一个任意数字,发生这种情况时,每个报告都会更改。 这主要发生在IE7 / Mozilla 4.0浏览器中。

我扫描了很多次代码,然后运行jslint,但是没有收到任何结果-有人知道导致此错误消息的JS问题的一般类型吗?

Some users are reporting occasional JS errors on my site.The error message says “Expected identifier, string or number” and the line number is 423725915, which is just an arbitrary number and changes for each report when this occurs.This mostly happens with IE7/ Mozilla 4.0 browsers.I scanned my code a bunch of times and ran jslint but it didn’t pick anything up – anyone know of the general type of JS problems that lead to this error message?