javascript

An explanation of web sockets and server-side Javascript (especially focused on node.js)

I want to create a chat room using HTML5 web sockets, but am pretty lost. From what I can tell, the following is required: A browser that supports web sockets (Chrome, Safari) Some kind of server-side scripting Some kind of client-side scripting I've got #1 down :) but #2 is seriously tripping me up. Beyond amateur PHP work (generall...

Rendering a different Javascript file in respond_to

Hi everyone, I am stuck in an (apparently) simple problem. In my event_controller I have the i_like_it action: def i_like_it @event = Event.find(params[:id]) ... # logic respond_to do |format| format.js end end In my case "i_like_it" is called with :method => PUT (it is an Ajax call, "i_like_it.js.erb" will...

JS: Error in IE, compatible in Chrome and Firefox

I'm having IE give me this error for a small function I wrote: Message: Object expected Line: 13 Char: 52 Code: 0 Here is my code (please excuse the formatting): function SectionTwo() { if (xmlhttp.readyState==4) { if( xmlhttp.status==200 ) { if( xmlhttp.responseText.indexOf( "404 Error" ) >= 0 ) { } ...

Javascript getSelection

Hello guys, I got another question related to the getSelection. I'm working on a WYSIWYG text editor and I'm using custom functions to apply HTML effect to the selected text. So far things are working great. Currently the way it works is whatever you highlight, it replaces the entire body of text in the textarea with what you selected...

Set dateformat once, so jquery and jqueryUI date picker use that date format

Is there a way for me to set the date format once to 'dd/MM\yyyy' and then have jquery's ui datepicker use that date? I don't want to set the date format everytime I use the datepicker. I am getting the format from a server-side config setting, so I can output this on every page request to a js variable on the page. ...

change text of asp.net button with javascript

I have a form submit button that has asp.net validators hooked up to it. If I make a javascript function to change the text to processing on click it does not work. The button flags the validators and also causes the whole page to post back. Heres the code I have: C# protected void Page_Load(object sender, EventArgs e) { btnPurcha...

jQuery click detection outside of specified area problem

Hey guys, ok, so, I have a jPlayer jQuery plugin playlist hidden on my home page (http://www.marioplanet.com). Now, it is hidden by default and is only supposed to be activated upon clicking the image labeled "Music" in the upper-right-hand-corner of my header <div>. This works great, and once an end-user clicks the image, a nice, slic...

JavaScript, passing value to function

Kind of stuck with this thing, that's why need help please. I am using HTML5 and JavaScript to insert text on an image and create a new image with the text on it. Everything is fine if I am adding the text manually, however if I am trying to pass the text to the function as a value, its not happening. Here's the function code below f...

Rhino load() function available in JavaScript provided by javax.script?

Some JavaScript files that have been developed for Rhino's shell use load() to load additional JavaScript files. I'm attempting to embed functionality from one of these Rhino JavaScript files using javax.script. Unfortunately, the load() function is not implemented by javax.script's JavaScript. When attempting to eval() a script containi...

Returning variable from onreadystatechange

I am trying to return a variable from onreadystatechange and seem to be having trouble with scope. Even if I set a global variable, when trying to retrieve my variable after the fact, its undefined. Not quite sure what I am doing wrong. I haven't done too much work with Javascript in the past 3 years. var lat; var lon; window.onload =...

Cycling between 3 images (mobile Safari)

I have the following javascript. It works well when I am cycling between 2 images, but when I add a third it does not work correctly. Here is my CSS: img { -webkit-transition-property: opacity; -webkit-transition-duration: 2s; position: absolute; width: 320px; height: auto; } img.fade-out { opacity: 0; } img....

Ajax.Request doesn't work in IE

Hi I using prototype javascript I am using ajax function which works perfectly in FF but not in IE var MOList_VenuePostBox; function getPreSearch(tid,tname){ include_js("http://" + getHostPath() + "/_scripts/lib/z_autocomplete_messagecenter.js", function() { //,{fetchFile:'/ajax/spot/getmyspots.aspx'} MOList_V...

Open Source Javascript PDF viewer

Is there any open source Javascript based PDF Viewer available? Any guide to developing this kind of script that renders PDF docs would be helpful. ...

JS: document.getElementById(var).style.display - Object needed error in IE8 only

I'm iterating through an array of strings (ids) and passing each element of the array to a function which either hides that element by id or shows it. for(var tag = 0; tag < idtagArray.length; tag++){UpdateImage( idtagArray[tag], xmlhttp.responseText);} And the UpdateImage function: function UpdateImage( usediv, data ) { if( data...

jQuery handle Ajax timeout?

Hi, I'm trying to catch Ajax timeout error with jQuery 1.4.2, but none of tutorial I found work. In Firebug, when timeout error fires. I see uncaught exception: [object Object]. Please help me handle Ajax timeout. Here's my JS code: $.ajax({ type:"POST", url:"/data/add/", data: { "date":$("input#date").val(); },...

AJAX with callback functions

I am having trouble access data within an ajax connection. Not sure what is wrong with my code. It seems as though it never reaches the 2nd function. Any ideas? function fetchgps(callback) { var url = "http://www.instamapper.com/api?action=getPositions&amp;key=584014439054448247"; var myRequest = new XMLHttpRequest(); myRequest...

How do I strip the first character

I am constructing a URL and I have escape($('#count_of_stations').html() The problem is the value will come in like this 1 station 2 stations I need to strip everything other then the first character, so is there a way to sent it with the " station(s)"? ...

#hash added by firefox and ie at the end of url in search-results page (Google personal search)

is there any way to avoid firefox and ie to reload the page adding the hash-tag to the url. due to that i refine results by time with adding &as_qdr=d to the end of url, i have a problem with theese hashtags in url, because anything behind them seems to be unfunctional. It does not happen with Chrome, but Firefox reloads the page after...

jQuery .each() Starting from an index other than 0

I'm just getting started with jQuery. I was using it to make a photo gallery that pulls photos and their information from Flickr. The script is shown below <html> <head> <title>Flickr Test</title> <script src="http://rhol.squarespace.com/storage/js/jquery.js" type="text/javascript"></script> <script src="http://rhol.squarespace.c...

jQuery outside events plugin not funcitoning properly.

I have downloaded the jQuery outside events plugin as Sarfraz suggested, which seems really great, except, I cannot appear to get it functioning correctly. Here is my code that I'm trying to call it with: $("#player").bind( "clickoutside", function(event){ if($('#player').is(':visible')) { $('#player').slideToggle(500); } }); ...