Skip to content
Advertisement

Tag: javascript

Difference between console.log and sys.puts in node.js?

In node.js you can use console.log or sys.puts to print out to the screen. What is the preferred method and what is the difference between these? Answer sys.puts simply prints the given string in the logs. But if you want to print a more complex object (Array, JSON, JSObject) you have to use console.log because you want to “look inside”

Is it possible to connect to SSH using JavaScript?

I know there is an implementation of VNC using WebSockets (http://novnc.com) but that still requires a server. I am looking to create a simple client-side JavaScript only (no Flash) connection to a port running SSH. I am guessing WebSockets is the only way to go since it does TCP. Any example code? Any other way? Answer Sorry, given your constraints

The best way to bind event on a cell element

I’ve a web page fulfilled by a JS script that creates a lot of HTML tables. Number of <table> created can vary between 1 and 1000 with 100 cells in each of it. My question is : how to bind efficiently the click on theses tables? Should I bind the click on each cell of the <table> or directly to

Fire a function on a element

I need to add a color picker to some input elements. I’m using: This works perfectly. The problem is that the page has a AJAX form, which – when submitted – will overwrite the previous form with a new one (new input fields etc). After that the colorPicker stops working. So how can I fire that function to the newly

Javascript regular expression: remove first and last slash

I have these strings in javascript: and I would like to remove the first and last slash if it’s exists. I tried ^/(.+)/?$ but it doesn’t work. Reading some post in stackoverflow I found that php has trim function and I could use his javascript translation (http://phpjs.org/functions/trim:566) but I would prefer a “simple” regular expression. Answer “Replace all (/…/g) leading

Advertisement