javascript

What is the difference between Array() and [] in Javascript and why would I use one over the other?

Possible Duplicate: What’s the difference between Array() and [] while declaring a JavaScript array? In JavaScript you can create a new array like: var arr = new Array(); or like: var arr2 = []; What is the difference and why would you do one over the other? ...

When loading an html page via ajax, will script tags be loaded?

When you load an html document using AJAX, what does it do with the nodes inside the HEAD tag: (script,link,style,meta,title) ignore them or load and parse them? And in the case of jquery 's ajax() function? ...

Adding optgroups to select using javascript dynamically

Hello! I have a dynamically populated (by ajax) select box with resulting options like that: <select id="destination" name="destination"> <option value="london-paris">London-Paris</option> <option value="paris-london">Paris-London</option> <option value="london-newyork">London-New-York</option> <option value="newyork-london">New-York-...

"'0.offsetWidth' is null or not an object" - Coda Slider - Javascript Error Question

I implemented the Coda Slider tutorial successfully that is located here: http://jqueryfordesigners.com/coda-slider-effect/ The slider works great but I am getting a javascript error that I am not sure how to fix. The error says: '0.offsetWidth' is null or not an object coda-slider.js, line 19 character 3 Not sure how to fix it. Any...

Close a jQuery UI Dialog from an element inside of it?

Here's a quick question that's probably simpler than I'm thinking. I'm populating a jQuery UI dialog with the resulting html from an $.ajax() call. In certain cases that html includes a button that when clicked, I want to close the containing dialog. Assuming that I don't know anything about the element that was specified to be the ...

Why do some websites access specific versions of a CSS or JavaScript file using GET parameters?

I have seen quite a lot of websites doing this (even stackoverflow itself) within their generated HTML source, accessing a specific version of a CSS or JavaScript file with GET parameters. What's the point of it? Example: <link rel="stylesheet" href="http://sstatic.net/so/all.css?v=6230"&gt; <script type="text/javascript" src=...

Rhino JavaScript and dynamic scope var creation

I am trying to define a dynamic variable within a function in Rhino JavaScript (specifically what is embedded in Java 6), but I don't want to resort to eval, and I don't want to have to reference it via this. Basically, I want to take an object, and turn every property into a var within the scope of a function... something like: var ab...

Facebook Connect JavaScript API - friends_get never returns from callback on ie6?

The following code works on all browsers that I've seen so far other than IE6, which gives me no javascript errors or anything but never calls the callback to friends_get. I would have expected that if facebook's javascript code for this was just broken on IE6 i would have been able information about that on the internet, am I just doing...

How does jQuery hijack "this"?

I'm just curious to know how jQuery is able to hijack the 'this' keyword in Javascript. From the book I'm reading: "Javascript the Definitive Guide" it states that "this" is a keyword and you cannot alter it like you can with an identifier. Now, say you are in your own object constructor and you make a call to some jQuery code, how i...

Firefox: Disabling exit alert boxes?

Is it possible to completely disable the JavaScript exit alert boxes that spring up when I try to leave the page? I'm running Firewatir on Ubuntu. ...

why does array.shift skip a value?

I have this function $(this).each(function(index) { arr[index] = ($(this).attr('id')); console.log(arr[index]); fullId[index] = "#"+arr.shift(); console.log(fullId[index]); }); The results I'm expecting are A #A B #B C #C D #D The actual results are A #A B Undefi...

What is 'click()' in JavaScript

I was playing around with JavaScript in FireFox, and hit a problem that is illustrated in the following example: <HEAD> <script type="text/javascript"> function click() { alert("click"); } </script> </HEAD> <BODY> <input type="radio" onclick="click()"> </BODY> When I click on the radio button, nothing happens, and no errors (in...

How can i use javascript to insert text into a textarea?

I need to insert some text into a textarea at the place where the cursor is, how can i do this without jquery? ...

Event handler cannot access Object method in JavaScript

How can I access util.log() method from a static html event handler? In other words, when I click the checkbox, I like to call util.log method. onclick="util.log(\'hey\')" <-- how to rewrite the event function here? I know all the answers are correct down here but is it possible to access local methods while insert the html into inne...

If Statement not working with And (&&) Operator

Hi all! I'm having a hard time writing up what seems should be a simple if statement! I need it to say if mod does not equal a, b, or c - then do this. Here is what I was trying but have been unsuccessful: var mod = CURRENT_MODULE_ID; if (mod != "5827289" && mod != "5195103" && mod != "5181422") { doSomething(); } When I type this ...

Replace Single Quotes in Javascript or JQuery

Hi All, i have an Html String in which i have some elements having single quotes.When i put this inside a $('varHtml'); Since the varHtml already contains some single quotes it qives an error, Can Somebody help me how to Escape the single quotes in the varHtml Thanks in Advance Thomson ...

getting diagonal and vertical adjacent cells of a table in jquery

Hello, I have a 4X4 table. I want to get to get adjacent that are vertical, and diagonal on the top on bottom. I don't have a problem getting them when the cell i click on is around the edges because i can use something like this. above = $(that).parent().prev().children().first() below = $(that).parent().prev().children().last() diagon...

How do I check if a checkbox is checked with JQuery?

I am trying to allow a click function if the user has checked a checkbox on the page. Otherwise, I want to add a class to the #additional_foreign button. I think I am close, but it doesn't seem to be working. Here is my code: if($('#foreign_checkbox').attr('checked')) { $('#additional_foreign').click(function() { alert('T...

JavaScipt: Unicode space character

I want to insert the space character into the innerHTML of a DOM element, but the space character must be declare in unicode syntax. For exxample, something like this: ...innerHTML += '\u83838383'; ...

JQuery Live and Sortable

I am trying to implement drag and drop so I can sort lists of data and update the database with the relevant positions. I have a working example but when I try to use the same code on lists that are brought in via ajax the event is binding but none of its methods are triggered and the items do not stay swapped, (They swap back when you ...