javascript

I have a problem with keydown event and autocomplete in Firebox on mac.

Hi, This is driving me nuts. Its a tough one to explain but Ill have a go. I have one input text field on the front page of my site. I have coded a keydown event observer which checks the keyCode and if its ENTER (or equiv), itll check the input value (email). If the email is valid and unique in the DB itll submit the form. Basic stuff...

jQuery is not a function error

What is wrong with this statement? message = $("#contact-form").find(".long-text"); if(message.val().length < 15) { message.css("border","2px solid red"); alert("Your message must be more than 15 character long"); } I get message.val is not a function error in Firebug? What could be the reason? NEW OK, now my form won't sub...

Javascript check for decimal place (check if value is an integer)

Hi, i am looking for an easy way in javascript to check if a number has a decimal place in it (is an integer) ... 23 -> OK 5 -> OK 3.5 -> not OK 34.345 -> not OK if(number is integer) {...} thx alot. ...

Find out if a Variable exists

Hello all, I would like to find out if a Javascript variable exists. This is what I have so far which was cobbled together from different forums: function valueOfVar(foo){ var has_foo = typeof foo != 'undefined'; if(has_foo){ alert('1 = true'); return true; } else { alert('1 = false'); ...

move input text from iframe to main window

I have an iframe on a page that allows us to upload an image, once it's uploaded it displays the url of the file in a text input field. On the main part of the page, we have our textarea where we write up our news posts. I'd like a way so that I can add a link on the iframe, next to the url field, that when clicked will automatically in...

Using Drop Down lists to hide/show with Jquery

Dear ALL, I am trying to do soemthing quite straightforward but can't get my head around the syntax. I have a dropdown list. The OPTIONs have two types of classes. If an OPTION with class 'less_than_3' is chosen we see an alert. And if an OPTION with class 'greater'- we see a different alert. Heres my attempt: (please note I originall...

ASCII Text String Shortening

I am not really interested in security or anything of that nature, but I need some function(s) that allow me to "compress"/"decompress" a string. I have tried Base64, but that has a big issue with the size of the string, it makes it longer. I also know about this Huffman stuff, but that doesn't work either because it too makes it longer ...

jQuery onclick pass post variables and reload page.

Can I pass post variables and reload a page on clicking an hyperlink? To be clear I have something like this. <a href="test.php?name=test">Click</a> If javascript is enabled, I think I can use "event.preventDefault()" to suppress passing as GET variable. So now onclick, name should be passed as post variable instead of get. If jav...

Vim like window manager

I'm trying to implement a window manager like vim does but in-browser with JavaScript. I got pretty much what I wanted working with jquery layout, but how I should manage my windows still elude me.. I can start with a single "window" and a empty buffer like vim does, then split it vertically or horizontally to get a split view of two or...

Javascript get current div content, add 2 divs inside parent

Ok I have a page setup that looks like this: <div class="parent">Content here</div> I want to grab each div with the class 'parent', and make it look like this: <div class="parent"> <div class="child"></div> Content Here <div class="child"> </div> I know how to loop through each div with the class 'parent', except I dont know how t...

Javascript webkitTransform within a for loop

Hey, I've come across a strange problem whilst trying to mimic the native iPhone page transitions (slide current page out and new page in). Here's my current code (extracted from a larger file, with no errors when debugging, so code logic doesn't seem to be the problem): Notes: A new page is created when a link on the current page i...

How to update Select menu with AJAX w/out <div> inside form

Hey all, I am using an ajax call to update a select menu. The ajax call puts the list into my select menu by running from a different .php file. Here is the JS insertion snippet: if (req.status == 200) { document.getElementById('countydiv').innerHTML=req.responseText; } else { alert("There was a problem while using XM...

How to access window object from XUL?

I'm trying to set an onLoad event to the current web page from a firefox extension. I'm using the gBrowser object but I'm not sure if this is the best way. I would like to set an onLoad event to the web page window to execute some actions of the plugin as soon as the page is loaded. Thanks in advance. ...

How do I check if GEARS is installed, using javascript?

Is it windows.gears != undefined or something??? I just want to use javascript to return true or false if the person has google Gears. ...

Best way to convert JSON data to an object in javascript

I am currently using eval in Javscript to convert JSON data returned from the server into an object. eval ("myObject="+data); I've been told that eval is 'evil' and can open up big security problems. I'm wondering - is using eval to convert JSON data to an object the accepted practice? Or is there a better way? Thanks, ...

How to check if anything is visible in a div

I have a script on my page which loads content from an ad network into a div. This ad network has an 80% fill rate i.e. it only serves an ad 80% of the time, the other 20% of the time it doesn't show an ad. Sadly, the ad network doesn't provide me with a callback to tell me when it hasn't served an ad. As a consequence, sometimes this di...

Can an object automatically delete itself in javascript once it has achieved its purpose?

I am wondering if it is possible for an object in javascript to delete itself once it has finished its task. For example, I have the following object... var myObject = Object.create(baseObject); myObject.init = function() { /* do some stuff... */ delete this; } myObject.init(); Does this work? If n...

What is the non-jquery equivalent of $(document).ready()?

What is the non-jquery equivalent of $(document).ready()? ...

Can JavaScript call ActionScript code?

Hey all.. I'm new to Flash. I have created a flv player that can play videos dynamically based on a user selection in a list component. I would rather not develop the user interface in Flash. Meaning, I'd like to bag the list component. Mostly because I am not very savvy yet. Is it possible to have javascript call actionscript? I would ...

Coloring a map depending on information (using google maps api or another api)

Hi, I am trying to build an application that will use an Api like google maps api (or any other api for maps) in order to color the states depending on some information that change. So for example, let's say I am going to color states green if they have more than 5 people online and this information will change every minute, how can i us...