javascript

How to avoid conflict between JQuery and Prototype

If a page has both JQuery and Prototype then I got conflict. There is a option to disable $ sign for JQuery so there is no conflict but, I have to use keyword JQuery instead of $. I wonder if there is any option for Prototype to solve this conflict. Is there any way to use both libraries without compromising their benefit or short keywo...

Remove any spaces while typing into a textbox on a web page

How could I, on the fly, remove spaces entered into a textbox while the person is typing? ...

Using jQuery to do an onClick div refresh.

This should work right? I have not a clue as to why it's not. I have to be doing something wrong. <div id="randomdiv">text</div> <a id="refresh">click</a> <script> $(function() { $("#refresh").click(function() { $("#randomdiv").load("index.php") }) }) </script> ...

HTML "overlay" which allows clicks to fall through to elements behind it

I'm trying to overlay a element on top of a webpage (to draw arbitrary graphics), and I've come to the point where I can stack it inside of a element on top of everything, but this prevents the user from clicking on any links/buttons/etc. Is there a way to have its content float on top of everything (it's semi-transparent, so you can s...

js syntax error when invoking mouseover callback

I have some javascript code that creates an img tag with a mouseover callback, and adds the img tag to the page. The problem is that a javascript syntax error happens (in the Firefox Console) whenever the callback is invoked. This code demonstrates the problem... var imgUrl = 'http://sstatic.net/so/img/logo.png'; var ...

JavaScript minifyer which can be integrated with a build of an ASP.NET application

Inspired by this answer.. Can you guys point me to something similar--something that can be integrated into a build-script or perhaps directly into Visual Studio? ...

sprockets: can I have two different javascript files included in two different controllers

I am working on a ruby on rails application. All the controllers have one javascript file. However there is a functionality ( call it business.js) which is needed by two controllers. Now just because two controllers need it , I don't want to put this logic in application.js which will make this logic available to all the controllers. I ...

Javascript: How do I check if the key pressed on a form field is a digit (0 - 9)?

I'm using the onkeyup event on a form field in JavaScript, and I'm wanting to check if the key the key pressed is a numeric digit - ie. 0 - 9, so I can then do something with the input. <input type="text" onkeyup="" /> Would I need to use Regex for this? Thanks ...

Please Help Me Learn to Fish - Javascript, Prototype and XML

I am looking for a good online reference to working with XML in Javascript. Specifically, I am using the protoype library. I have my ajax response with a valid responseXML document. I can find all sorts of online examples for looking at the data in the first child node of the first element tagged 'X', but that doesn't help me. What I ...

How do you encode an Object in a Web Worker for it to be passed via postMessage?

Internally, Firefox will JSON encode an object passed via postMessage to and from the Web Worker. However, this only works in Trunk builds of Firefox (3.6+) and not in Firefox 3.5, so the question is really how to add backwards support of this operation to the current platform. The window.atob() and window.btoa() methods had been suggest...

ignore base href when submitting form, without using Javascript

Many of the web pages I am working on use files such as images and scripts that are mostly on a different domain from the page itself, so I put a base tag in the head of the page. For most purposes, this makes the site easier to work on. However, the page has a form, and I want to make the form submit to the same domain as the page. I wo...

Checking the value of System.Gadget.Flyout.file

I've been working on a Windows SideBar Gadget wherein I have multiple flyout pages. When I go to display one, I want to check if it is already active or not, so I thought I could just check the value of System.Gadget.Flyout.file. However, when I press the button control that causes this flyout to pop out, the background of the gadget dis...

PHP scope -> Javascript scope pattern?

Anyone have any clean patterns for getting php vars into the js scope? Two ways I have done it before is either injecting it with an actual call from the base template inside a document ready wrapper. (jQuery/Smarty Template) {literal} $(document).ready(function() { TargetClass.targetVar = {/literal}{$phpVar}{literal}; }); {/liter...

Basic jQuery slideUp/slideDown help.

I was wondering if there was a function that I can add to this, that would show the data again, as in make it slide back down or something after a given set of time so you can go back and re-enter your data. It currently just slides up after submit, and then shows the text. $("#help").slideUp(function() { $("#help").before('<div class...

asp:Textbox off focus?

I want to save the contents of a multline textbox when off focus - i.e. user has finished typing and clicks outside the textbox so it goes off focus. I can handle the saving- thats no problem, but is there an off focus function? I don't mind a javascript version. I must be using asp:TextBox though. I tried with onFocus, OnServerChange,...

Is there a good way to attach javascript objects to HTML elements?

I want to associate a javascript object with an HTML element. Is there a simple way to do this. I noticed in the HTML DOM (http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html) defines a setAttribute method and it looks like this is defined for arbitrary attribute name. However this can only set string values. (You can of course use...

Binding arrow keys in JS/jQuery

How do I go about binding a function to left and right arrow keys in Javascript and/or jQuery? I looked at the js-hotkey plugin for jQuery (wraps the built-in bind function to add an argument to recognize specific keys), but it doesn't seem to support arrow keys. ...

JQuery color animations not firing reliably

I'm having a problem using the jquery hover events. I've created a reduction of the problem. You can find a working demonstration here. I can reproduce this after moving the mouse around in IE, FF, Opera, and Chrome. I'm using queued animations in my mouseover event. Roughly 1% of the time, the color of the td elements is left as #...

Order of attribute evaluation in Javascript object literals

I'd like to write something like this (in Javascript): var obj = { left: left, right: -(left += increment) }; This will only do what I want if I can be sure that attribute values will be evaluated in the same order that I write them. Does the language make such a guarantee anywhere? ...

How to make a continuous scroll with JQuery?

Hi Guys, I have this site I am developing: http://tinyurl.com/l7uzzp - I made the scroller with the following code: $(document).ready(function() { function scrollIt() { $('#featured-brands div#scroll').animate({ marginLeft: "-4550px"}, 85000, "linear").animate({ marginTop: "-223px" }, 2...