javascript

JavaScript detect an AJAX event

Okay so basically I want to have a bit of javascript on a page that somehow attaches some kind of global event listener that can detect and do something if an ajax request is made (without directly calling it from the call), regardless of how the ajax call is made. I figured out how to do this with jquery - if the ajax request is being...

What is a good setTimeout interval for polling in a IE?

I have an ActiveX object (who source code I have) running in a browser (IE). The ActiveX object has a UI, which raises events. I want to respond to those events in the browser. I don't want to invoke JavaScript functions from the ActiveX object events: and therefore, instead, I want the JavaScript to poll a method of the ActiveX object ...

Calling JS functions assigned to varibles

Some time ago I asked a question about the same issue, @BenAlabaster explained it thoroughly in his answer, I guess I am still missing a piece of logic here. I tried to call functions that are assigned to variables like I've shown below, in the last function. Well it didn't work. Assuming it happened because the variable functionThree i...

Problem with Google Chrome and Javascript. Guru needed!

Hello, i have a strange problem only in Chrome using an iframe but working in all others common browser. the problem: If i type in the IFRAME and then press the button to send, it work fine, the focus back to the IFRAME and the cursor BLINK. But if i type and then press ENTER to invoke the event handler function, the focus back but the...

how to replace all using regexp (javascript)

var text = "'Hello'World'''"; how to replace all ' and Hello and World to ' result = "'''''''" ...

JavaScript .push() inside function is overriding global variable

Hi! I have the following problem with .push() method: var myArray = ["a", "b", "c", "d"]; function add(arr) { arr.push("e"); return arr; } add(myArray); // myArray is now ["a", "b", "c", "d", "e"] Why it overrides myArray? Can't understand that... ...

Will Javascript V8 kill all the other server-side dynamic languages? Ruby, Python, PHP?

That's all. It should be very nice to share the same libs on the client and on the server or not? Are JS VMs like HotRuby (http://hotruby.yukoba.jp/) a "real world" alternative or just a toy? PS: if I ask it is because I'd like know it, please don't close this question but just share your opinion. I'm not interested in programming lan...

How to call a JavaScript callback from a Java applet thread?

I have some long-running Java code running in a thread started by a Java applet. As soon as the code has finished, it has information for the user. I'd like to pass this information to a JavaScript callback in a thread-safe way. Just using the Java DOM API to modify the HTML document is not good enough, unless my JavaScript callback gets...

jQuery / JavaScript - Trigger hover on a element when mouse over on another element

Is this possible? My HTML looks like this: <ul> <li> <a> link </a> </li> <li> <a> link </a> </li> <li> <a> link </a> <ul> <li> <a> sub-link </a> </li> <li> <a> sub-link </a> </li> <li> <a> sub-link </a> </li> </ul> </li> </ul> Basically I want to trigger the hover CSS rule on the parent menu ...

How to best calculate the bytes of text in a TextArea

I need to find a way to accurately calculate the byte size of the text inside a particular textarea. I am working in .Net so I have access to those libraries, but I'd prefer a Javascript solution. How many bytes is each character worth? What would be the most efficient way to count and multiply? Or am I missing a better way entirely?...

JavaScript - Encapsulation ?

A long time ago, I saw someone encapsulate their entire javascript block with code something like the code below: <html> <body> ... <script> (function(){ ... })(this); </script> </body> </html> Questions: Is the code above correct? What benefit is there to encapsulating the entire javascript block like denoted above? ...

Insert HTML after a selection

I want to be able to double-click to select some text in a div, which then triggers a JavaScript function that inserts some HTML after the selected text, much like the 'edit/reply' feature in Google Wave. I have already established how to trigger a function on double-clicking, it is locating the selection and subsequently inserting HTML...

how to get style="i want the css code" using regexp (javascript)

var text = '..<anything><anything style="color:red;">hello</anything><anything style="color:blue; font-size:1em;">hello</anything></anything>...'; or var text = "..<anything><anything style='color:red;'>hello</anything><anything style='color:blue; font-size:1em;'>hello</anything></anything>..."; result: array[0] = "color:red;"; arr...

how to correctly use .each here?

This is basically for a library I'm building. In this module I'll attempt to build a debug helper library to help me during debugging. My problems here are that when FDL.D.ListEvents() is called a couple of awkward things happen: 1) If I include enough _logEvent() calls, the last few stop closing their groups at the console, which m...

Trying to clean out form inputs with jQuery so I can add it back into the form

I have a pretty simple HTML form where users can enter in information about a person. Below that form is a button which allows them to 'add more'. When clicked, the 'person' form is copied and appended to the page. The way I used to do this was to take my HTML file, copy out the relevant section (the part that gets 'added more') and the...

How do I share sign-in information between Outlook Web Anywhere and Exchange Web Services?

I'm attempting to develop a chrome extension which will allow a user to use Outlook Web Anywhere more effectively. During development, I noticed that there doesn't appear to be any way to share login information between OWA (which uses form based authentication) and Exchange Web Services (which I'm using for the bulk of the extension), ...

customized ,manipulate textbox ( how to modify it's apparence )

hi, does anybody has a clue on how to make a custum textbox like component that act quite like the email field used on facebook or hotmail when sending messages. the main function of this textbox is that it separate autamaticly the emails or the friend names and transform them into a rectangle with a tiny x to remove the item if the use...

Why am I not getting the value from onChange with Select?

Testing part of a form. So, right now I just want to alert what the user selects: JS: function getData(title) { alert(title); } HTML generated by PHP: <select name="currentList" onChange="getData(this);"> <option value="hat">Hat</option> <option value="shirt">Shirt</option> <option value="pants">Pants</option> </...

What charset to use when sending a response to a javascript XMLHTTPRequest 'get' request

I want to send a response to a get request made by the javascript object 'XMLHTTPRequest.' The response content-type will be 'text/plain'. I would like to add a 'charset' to that (i.e. 'Content-Type:text/plain;charset=UTF-8') What encodings does javascript work with natively and what encodings will work with javascript on all browsers...

Javascript cookie expiration/deletion on different browsing scenarios

A client requested cookie functionality where if the browser is not closed, the cookie has a 30 minute expiration, but then it needs to be removed if/when a user closes the browser. Here's how I was going to do it: delCookie = function() { document.cookie = 'cookieName=;expiration=Thu, 01-Jan-70 00:00:01 GMT;'; }; $(window).unlo...