javascript

Autocomplete textfield

I'm trying to make an autocomplete textfield for my Rails app, following the Agile Web Development with Rails, 3rd Ed example. But if I simply paste their demo code in: <%= stylesheet_link_tag 'autocomplete' %> <h1>Editing user</h1> <% form_tag :action => 'update', :id => @user do %> <%= error_messages_for 'user' %> <p>Username<br...

jquery: getting elements from xml in different order

Hello, The xml response from the ajax request looks like this: <element type='type1' /> <element type='type2' /> ... <element type='type1' /> I want to insert dom elements based on the xml, but I want them to be ordered as: first all the elements of type1, then all the elements of type2. It made sense for me (and I also read some di...

dynamically changing position property in css file after d'n'd

hey guys, hope you can help me, again :) i want to build a little webbased gui designer. the user can switch into editor-mode and can place the components wherever (s)he wants via drag'n'drop. when (s)he switches back to user-mode i want the position-details in the external css-file to be updated via javascript. i looked into some examp...

When calling a Javascript function, how do I set a custom value of "this"?

I'm using jQuery and I have a function that serves as an event callback, and so in that function "this" represents the object that that captured the event. However, there's an instance where I want to call the function explicitly from another function - how do I set what "this" will equal within the function in this case? For example: ...

Top of Page Javascript Bookmarklet

Can anyone tell me how to turn <a href="javascript:scroll(0,0)"> Top</a> aka the Top of Page link into a Bookmarklet. Not very knowledgeable with JavaScript and cannot get this into want I want it to be. Or if I am using the wrong code, then can you fix it for me and turn it into the bookmarklet. ...

Javascript syntax

How do you say if (A == 0) OR (B == 0)? ...

Why is this XMLHttpRequest sample from Mozilla is not working in Firefox 3?

I'm trying to get the sample code from Mozilla that consumes a REST web service to work under Firefox 3.0.10. The following code does NOT work in Firefox but does in IE 8! Why is this not working? Does IE 8 have support for XMLHttpRequest? Most examples I've seen use the ActiveX allocation. What should I be doing? XMLHttpRequest...

How can I hide a TD tag using inline JavaScript or CSS?

How can I hide a <td> tag using JavaScript or inline CSS? ...

Qwerty Keyboard in HTML

I need a QWERTY keyboard using HTML buttons, which enters the typed info into a text field. I can put one together, but it seems that this must have been done before, and I hate to reinvent the wheel. Does anyone know where I could find code for something like that? ...

COMET javascript library

I am looking for a simple and reliable Comet javascript library. I want to keep a persistent streaming of data from my server (via PHP script) to the client side. I tried building my own using the iframe technique, but there are lots of issues with safari which I experienced. I am just hoping someone else has created a simple library for...

how can I reload an update panel onclient side using javascript?

I have a gridview button that I programmatically created and I want to load an update panel on the client side with the sent data. I have a hidden value field that gets its data on the click of the gridview button and the dropdownlist in my updatepanel depends on that value. ...

Generate image data from HTML Canvas element

What is the best way to generate image data from the contents of an HTML canvas element? I'd like to create the image data such that it can be transmitted to a server (it's not necessary for the user to be able to directly save to a file). The image data should be in a common format such as PNG or JPEG. Solutions that work correctly i...

CollapsiblePanelExtender Click Event

I have a a CollapsiblePanelExtender with the usual extend and collapse buttons....I would like to have a click event fire off when the extender is extended and a different click event fire off when the extender is collapsed. But the most important event is when it is extended. I could live without a click even on collapse. Most of the ...

Javascript way to list available plugins for IE

Is there a quick way to get a list in JavaScript of the available Active X plugins? I need to do a test to see if a plugin has been installed before I actually try to run it. In effect I want to create a page that says 'Plugin Installed and properly Working' or have it fail gracefully. I'm not sure how to have it fail gracefully if ...

How to detect if a user is running IE 6?

I need to be able to tell if a page is being viewed in IE 6. How can I do this in javascript while ignoring version like 7, 8, or other browsers? ...

inserting javascript variable into html output of .innerHTML =

I am trying to insert a variable passed to my function into the output of my .innerHTML = code but do not know how to properly insert it into the HTML output. function playsong(song) { parent.document.getElementById('player').innerHTML = '<object width="199" height="26"><param name="movie" value="audio_player_black.swf"><embed src="...

javascript server under XULRunner fails.

I'm trying to debug a DOM scraping packaged called crowbar. Anyhow, when I run I get: Error: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIServerSocket.asyncListen]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://crowbar/content/crowbar.js :: onLoad :: l...

What is the best way to duplicate a calculation in Ruby & JavaScript?

I have a Ruby on Rails application and I need to duplicate some computations in both Ruby and JavaScript. Ruby is used in the server side but I also need to compute a students grade on the browser using JavaScript. My first thought is to build up a JavaScript function using strings, convert it to JSON, ship it to the browser where it i...

How can I make a jQuery function that shrinks a string using a binary search method?

I am trying to create a jQuery function that will take a string and a fixed width as an input, then through a binary search method (for efficiency) "shrink" that piece of text so it's no longer than the fixed width. This is what I have so far: function constrain(text, ideal_width){ var temp = $('.temp_item'); temp.html(text); ...

ASP.net not generating javascript for some User Agents

***************Edit 2***************** I figured out the problem... But I don't like the implications. I was testing our iPhone targeted mobile application earlier and using a plugin to mask Firefox's User Agent String as an iPhone. .Net was infact NOT generating the required code for post backs based on that piece of information alone...