javascript

What's your favorite JS/CSS drop down menu?

Looking to implement one on a website, just curious what everyone else has used and what kind of experiences they've had EDIT I'm also not a huge fan, but the client is insistant and for this case they can click on the "hoverable" part and then get to the same pages in the dropdown from there so basically this will just be a way to get ...

What is the Fastest way of looping over an array on javascript?

Any ideas? See also (dups or near-dups): What is the best way to do loops in JavaScript What’s the best way to loop through a set of elements in JavaScript? ...

How to disable scrollbars with JavaScript?

I need to lock the browser scrollbars when I show a div that represent a modal window in Internet Explorer 7 only. Googling I found that I can use document.body.style.overflow='hidden' but this doesn't work for IE7. I also tried with document.body.scroll="no" which works but only after I mouse over the scrollbar :-S Does anybody knows a...

Setting properties on anonymous DOM elements through JavaScript?

Let's say I'm generating markup through server-side code. I'm generating a bunch of HTML tags but I want to add custom attributes (properties). In JavaScript (if I had a reference to the DOM node I could write): var myDOMNode = ... myDOMNode.myCustomAttribute = "Hi!"; The issue here is that I don't want to qualify every element with ...

What is the best way to access ASP.net Session Data using JavaScript?

How can you make the ASP.net Session Data available to a JavaScript method? I found this link when I googled. Anyone has a better trick that does not use the ScriptManager? ...

Is there a Javascript equivalent of Ruby's andand?

In trying to make my Javascript unobtrusive, I'm using onLoads to add functionality to <input>s and such. With Dojo, this looks something like: var coolInput = dojo.byId('cool_input'); if(coolInput) { dojo.addOnLoad(function() { coolInput.onkeyup = function() { ... }; }); } Or, approximately equivalently: dojo.addOnLoad(func...

JavaScript: Setting methods through prototype object or in constructor, difference?

Could you explain the difference between setting methods in the constructor and through prototype object? The following code shows these two ways of setting the methods - say_hello and say_bye both work fine: function MessageClass() { this.say_bye = function() { alert('see ya'); }; } MessageClass.prototype.say_hello = function() { al...

Cookie not being sent by IE7

I have two copies of IE7, same exact security settings and same exact builds. Two different machines, both running WinXP. In my application, my cookie headers are being properly sent to the server on one version of IE. No other cookies are being sent in another version. What are some points to troubleshoot in this scenario? ...

ASP.NET broken rendering of Validation client side code in Firefox

This one has been a stumper for me. Its very easy to duplicate though a rather obscure issue. It came about as I was doing some javascript work on a web page yet also make use of the validation controls that ASP.NET provides. Some specifics up front: using a Vista-based development machine with the 3.5 framework and IIS 7. I also hav...

Ruby on Rails Ajax rubberband

I want my users to be able to do a rubberband selection in a image for a Ruby on Rails application. Has anyone seen any good plugins that do this or make it easy for me to implement it? ...

Use RegExp to match a parenthetical number then increment it

I've been trying to find a way to match a number in a Javascript string that is surrounded by parenthesis at the end of the string, then increment it. Say I have a string: var name = "Item Name (4)"; I need a RegExp to match the (4) part, and then I need to increment the 4 then put it back into the string. This is the regex I have s...

Difference between (function(){})(); and function(){}();

This is something I haven't quite figured out yet, but I have been using function(){}() just because my VIM syntax highlight screws up if I add the parenthesis, although I've seen (function(){})() around many times, maybe its an IE thing? edit: var singleton = function() { // code }(); var singleton = (function() { // code })(...

How to get file name from full path using javascript

Hello, Just wondering, is there any way that I can get the last value (based on the '\' symbol) from a full path? Example: C:\Documents and Settings\img\recycled log.jpg With this case, I just want to get "recycled log.jpg" from the full path in javascript. ...

What is the best menu for an ASP.Net application?

What do you find to provide the best menu for an ASP.Net 2.0 - 3.5 web application? Suggestions do not have to particularly be ASP.Net controls, but could be other menu's that work well within an ASP.Net web application. I would like for the suggestions to be options that do not require purchasing or royalty fees. OpenSource suggestions...

document.getElementById fails in a function

I have encountered odd behavior when using document.getElementById tonight. Duplicated in Firefox 3 and Safari. Basically, it finds the div with id "divid" in Example1. However, in Example2 it always returns null. What's going on here? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-stri...

Where is XMLHttpRequest.responseStream defined?

Take a look at the graphics part of the GoogleAPI reference. It says that loadImage takes either a string, or the responseStream property of an XMLHttp. By XMLHttp, I assume it means XMLHttpRequest. My problem is that I can't find documentation for this field (the responseStream field) anywhere. I've had no luck googling it (ironc), it...

Links to AJAX calls do not work

Hi all i am writing a Rails application and i include some link_to_remote links The generated code is <a href="#" onclick="new Ajax.Request('/b10/categories/games?category=Action', {asynchronous:true, evalScripts:true}); return false;">Test</a> That works perfectly fine on Safari and Firefox but when i try to click the link on IE7 and...

Grouping Regular expression BackReferences

I have the following RegEx id=(.*?) | id="(.*?)" The reason for this is I am trying to replace Ids from the browsers DOM using JavaScript. IE, however strips quotes from element atributes as it appears not to require them in the DOM The problem I have is that the backrefererences from each alternate statement are in separate groups (...

How to determine if a javascript was already loaded by other html file

How to determine if a javascript was already loaded by other html file? I want to reduce the redundant loading of the javascript files to decrease the loading time of my webpages. ...

How to create my own JavaScript Random Number generator that I can also set the seed

The JavaScript Math.random() function returns a random value between 0 and 1 (automatically seeded based on the current time (similar to Java I believe)). However I'd like to make a more robust function that accepts a min, a max, and (optionally) a seed. I found this code kicking around and it appears to work fine for getting a random ...