javascript

How do you set page level, page-SPECIFIC javascript events using a ContentPlaceHolder?

I previously asked how to include Javascript in my page when I split the page into a MasterPage and ContentPlaceHolder (.NET 2.0 app) The issue was I only wanted the javascript functions on THAT page so I couldn't just put them on the masterpage. Based on the answers, I will inlcude common fucntions through MasterPage and can put the p...

Is it possible to run XMPP based PHP and Javascript Multiplayer Network Game in FaceBook?

Hi, let me introduce my story first. To develop a multiplayer network game in facebook, flash used to be a king but it consumes a lot of resources for client and I feel like it isn't worth for a card game. So I come with an idea that front-end will use Javascript (of course with jQuery) and backend with PHP. But for real-time communicati...

Clean Microsoft Word Pasted Text using JavaScript

I am using a 'contenteditable' <div/> and enabling PASTE. It is amazing the amount of markup code that gets pasted in from a clipboard copy from Microsoft Word. I am battling this, and have gotten about 1/2 way there using Prototypes' stripTags() function (which unfortunately does not seem to enable me to keep some tags). However, even...

jQuery: Using normal function value as jquery value

Essentially i'm trying to get the value 'col' that is set in the html, and use it as the value for backgroundColor. Here's the script: function bgc(col) { $("#BG") .animate({ backgroundColor: "col" }, 1000) } Here's the html: <div id="BG"> <a href="#" onclick="bgc(#ffffff);"></a> </div> Any help would be great, i've be...

Ruby javascript unescape equivalent

I want to unescape the following string: '\u00020\u0002Standard\u00023\u0002Doe John\u000169\u0002\u0010\u0002Lorem\u0002\u0011\u0002Ipsum\u0002\u0014\u0002' Javascripts unescape function works ok, however how can I unescape it in ruby? Take in mind that unescape(previousString) is 0Standard3Doe John69LoremIpsum. ...

jQuery way to handle select lists, radio buttons and checkboxes

When I handle HTML form elements with jQuery, I always end up with an ugly mix of jQuery syntax and plain JavaScript like, e.g.: function doStuff($combo){ if( $combo.get(0).options[$combo.get(0).selectedIndex].value=="" ){ var txt = ""; }else{ var txt = $combo.get(0).options[$combo.get(0).selectedIndex].text; ...

Scrolling a Div programatically using say Javascript

Hi I have a jqgrid which is embedded in a Div. I am deleting records from the grid and reloading the grid using grid.Trigger('reload'). The width of the grid is considerably high so it has a scroll bar. Now I scrolled through the end of the grid horizontally before deleting records. Each time I delete the records and reload the grid, t...

Overriding check box in JavaScript with jQuery

Help with unit testing checkbox behavior. I have this page: <!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(function() { $('<div><input type="checkbox" name="makeHidden" id="makeHidden" checked="checke...

toString and valueOf truncates trailing 0s after decimal

In javascript, I've noticed that toString and valueOf truncates trailing 0s after a decimal. For example: var num = 0.00 var num2 = 0.0100 num.valueOf() or num.toString() // outputs 0 num2.valueOf() or num2.toString() // outputs 0.01 Is this normal behavior and is there someway to retain the trailing 0s? EDIT: I changed my original ...

How do I parse this invalid JSON string in jQuery?

Hi, I am looking to access the various bits of data in this data attribute: <div class="location" data="{id: 4, point: {lng: -71.413364, lat: 41.673681}, category: 'Restaurant'}"> The data attribute is easy enough to reach in jQuery, of course. But the string seems to be a non-standard or invalid form of JSON. I've tried JSON.pars...

JavaScript BubbleSort

Hi, Have a bubblesort routine similar the this. I need to make it more efficient by stopping the loop when the array is sorted or if the array is already sorted. function sortNumbers(listbox) { var x, y, holder; // The Bubble Sort method. for(x = 0; x < ranarray.length; x++) { for(y = 0; y < (ranarray.length-1); y++) { ...

Looking for examples of well-architected Rails/Javascript/AJAX apps

I feel like each time I start a new Javascript-heavy application, I begin to bumble around more and more as additional client-side code is written. The code structure of a Rails app is pretty well dictated by the framework, but developers usually invent their own structure for their Javascript and AJAX interactions. I'm looking for web ...

jQuery::List of image elements. Trying to make them into a slideshow

I managed to design a small 4x4 grid filled with images. Currently, I am styling the ul element using jQuery. <ul id="imagegrid"> <li> <img src="..."> </li> <li> <img src="..."> </li> </ul> So, when I click an element inside this list it just zooms up and shows as a larger image. Now, if I want to simulate a slideshow,...

Loading non-RJS javascript via ajax in Rails

I've written a rails module that generates some javascript for a google map. As the user makes changes on the webpage, I use observe_field to call back to the server to regenerate the map's javascript (without updating the whole page). I'm having trouble finding a good way to insert the new javascript into the page. I've tried <div id=...

Tabbed browsing, programaticaly navigating to another open tab

Hello, I'm in a discussion with my co-worker. We have a web application in a tabbed browsing environment, say with 2 tabs open. Tab2 has a link to tab1, when I click the link, it opens tab1 in a new tab. We want to detect if tab 1 is already open, if so then set focus to tab1 (and not open a new window). He has gotten this working i...

[javascript]Where are all functions in IE?

If i want to take all functions and variables declared in my program in firefox i just iterate 'window' object. For example if i have var a=function() {}; i can use a(); or window.a(); in firefox, but not in IE. I have function iterating window object and writing all function names declared in program like that: for (smthng in window) {...

What's wrong with this regex (VBScript/Javascript flavor)

I'm trying to run a regular expression in VBA code that uses Microsoft VBScript Regular Expressions 5.5 (should be the same as JavaScript regex) regex: ^[0-9A-Z]?[0-9A-Z]{3}[A-Z]?([0-9A-Z]{6})-?([0-9])?$ input: X123A1234567 match: 123456 The six characters I'm interested in give a good match of 123456, ignoring the last (check) digit. ...

controling a float value with javascript

Hi, to control my input type and verify that its value is pretty a float in my form i deal with it in javascript like that: function verifierNombre () { var champ=document.getElementById("nperformed"); var str = champ.value; if(str.value==' '){champ.focus();} if (isNaN(str)) { alert("Invalid Valid! the field must be a number"); champ.fo...

What future JS libraries have against ASP.Net and JSF components libraries?

Could you people share your opinions about future of JavaScript libraries as compared to ASP.NEt and JSF component libraries? Do you feel that Pure JS components are going to live around us for quite a some time? Or ASP or JSF would be a safe investment? ...

jQuery('body').text() gives different answers in different browsers

My HTML looks like this: <html> <head> <title>Test</title> <script type="text/javascript" src="jQuery.js"></script> <script type="text/javascript"> function init() { var text = jQuery('body').text(); alert('length = ' + text.length); } </script> </head> <body onload="init()">0123456789</body>...