javascript

Preferred method for waiting for AJAX in JavaScript

I find myself having to get around waiting for AJAX in jQuery often these days. Problem is, I have to do loops and crap to wait for them. What are some ways that I can wait for the AJAX event to finish before executing code (preferably without making extra functions)? ...

button height problem when using 
 char for line break

i'm using the char to make a line break in a button label. here is the code: <html> <input style='width: 50px;height:60px;' type='button' value="abc" /> <input style='width: 50px;height:60px;' type='button' value="abc&#10;asd" /> </div> the problem is that a button that's has the char in his label is not in the same he...

Reading Server Side file with Javascript

Does anyone know of a tutorial on how to read data from a server side file with JS? I cant seem to find any topics on this when I google it. I tried to use but it does not seem to work. I just want to read some data from a file to display on the page. Is this even possible? var CSVfile = new File("test.csv"); var result = CVSfile.open("...

Find a Text and scroll into it with javascript

Hi everybody, I have a div that contains hundreds of lines. I want to create a function that allows me to find a text and scroll into it: function findAndScroll(text) So, I enter the wanted text in an input text, I click on the "Go" button that will trigger the "findAndScroll" function then I get scrolled to that text. Before coding...

loading a function onclick

Hello. I have the following piece of code <a onclick="$('#result').load('codes/test.html');$('#result').show();" >XHTML code</a> it loads perfectly the content of test.html in the result div and also make it visible. Until this point all are good. When I try to add a function prettyPrint() which apply some modifications on the text an...

jqGrid setCell function 5th parameter and edit mode

I have a jqGrid where I want all the rows to be in edit mode. Under certain conditions, however, I want a cell in that row to be readonly based on some condition of the row data, but I can't seem to get the grid to bend to my will (yet). This is what I currently have. $(grid).addRowData(...); // omitted for clarity $(grid).jqGrid('ed...

Javascript "<body onload=...>" in Drupal

I'm trying to integrate a javascript library for drag&drop on tables into one page of my custom Drupal module. I've included the js file using drupal_add_js, but I don't know how to initialize it. The documentation for that library states that an init function should be called like <body onload="REDIPS.drag.init()"> How would I do th...

Javascript/Prototype adding two event handlers to a single field when I just want one.

I'm using prototype to attach event handlers to a number of form fields. The form fields are named "ContactAddress", "ContactCity", "ContactState", "ContactZip" as well as another set that begins with "ContactProfile". Now, the event needs to be able to tell the difference between when I'm updating a "Contact" field and a "ContactProfi...

Reading cookie value in Rails

I successfully set a cookie in JavaScript: var date = new Date(); date.setTime(date.getTime()+(1*24*60*60*1000)); //one day expiration date var expires = "; expires="+date.toGMTString(); window.name = date.getTime(); document.cookie = "window_name="+window.name+expires+"; path=/"; Then in rails I try to read (I've tried both of the fo...

any JavaScript obfuscators that dont use eval in resulted obfuscatored code ?

i am looking for a Javascrit obfuscator tool that dont use eval in resulted obfuscatored code. All tools i saw use eval in resulted code. ...

JavaScript Operator Precedence logic confuses me...

The operator precedence table I can find is: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence according to the table, both '>>' and '*' are left-to-right associate, and '>>' have higher precedence, so I think a >> b * c should explain as (a >> b) * c however, my test in Firefox (using Firebug), tell m...

XSLT Stylesheet switcher

Is there a way to switch a CSS stylesheet using XSLT? We are trying to do this without Javascript or include different files based on what CSS Stylesheet is used. Example: XSLT for normal view. Click a link and switches the stylesheet to view a Text Only view for accessibility and screen readers to use. At the same time getting rid o...

Does html5 gelocation method position.address.city only work in Firefox

Does the city method only work in Firefox? for example if I wanted to print the city of the user: if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(location) { document.write(location.address.city); }); } If this is true, what's the best way to find a users city? Take the lat and long a...

Check number of list items and columnize if condition exists

Example page: http://vincent-massaro.com/columns/columns.html On this page, there are two ordered lists, one with four items, and one with eight. I need to write a condition that checks how many list items are in each ordered list, and if it's more than four, split them into columns; if there are less than four, don't split into columns...

How do I link to a Blogger post with a post ID?

If I have the ID of a post on a Blogger blog, how do I translate that ID into a URL which links to the post? My ultimate goal is to pull posts from my Blogger site to my own site, and then be able to permalink to the actual posts. I'm doing this by parsing the RSS feed for my blog with Javascript. Unfortunately the "link" field in the R...

Is there any way to use subtitles with mp3s?

I have some .mp3 files of conversations with really bad audio quality that I am displaying on a web page using JavaScript. I was wondering if there was an elegant solution to display these mp3s with subtitles. See the page below for an example: http://bit.ly/ceMihE I came across this jquery plugin which does something similar, but usin...

Do "" and '' have different meanings in JavaScript?

Possible Duplicate: When to Use Double or Single Quotes in JavaScript Hello, Do "" and '' have different meanings in JavaScript? Because I keep seeing those two usages in Jquery, for instance. $("") and $('') Thanks for helping ...

Optimising Images for Internet Explorer

On a site of mine, my client is reporting that images that are reduced in size by code (i.e. specified a width/height) are appearing jagged and pixellated. I have asked her what browser she uses and inevitably it's Internet Explorer. Is there a way to optimise images in IE or do I need to manually resize the images on photoshop before ...

Injectng a new history entry without changing the url. Like google maps does.

I'm trying to find the best approach not to break the back button in my javascript application. In my research I'm trying to see what the state of the art is. So I turned to google maps to see how it works. It does have back/forward functionality, but it doesn't change the url when generating a new history entry. Try to go to http://ma...

selectedIndex is returning "undefined" as value

Forgive me if this is a stupid question; it's been many years since I've worked with javascript. This is actually javascript and html rendered via PHP in Joomla, but I've tried using the same code in a plain old local HTML file and I'm getting the same error. I have a select field with several options, and onchange I want to set the valu...