javascript

Facebook new js api and cross-domain file

Hi all, I am building a simple facebook iframe application. I've decided since the code is separate from facebook none the less, I will also create a connect website as well. In my connect website I'm trying to figure out the following: I am using facebook's new api and I am calling the init function. I can't seem to figure out where I...

Javascript Prototyping Question

I'm just reading about Prototypes in JavaScript and Douglas Crockford offers and excellent way to select a new objects prototype but can anyone explain (below) why obj01's type equals 'object' when I pass it in function as it's prototype? if (typeof Object.beget !== 'function') { Object.beget = function (o) { console.log(t...

How can I set the focus to a certain element in a form using JavaScript?

My page has a form that has a text field in it. I'd like to set the focus to that text field as soon as the page loads, so that users do not have to click it to start typing. How can I do this? ...

Use a JSON array with objects with javascript

Hi, I have a function that will get a JSON array with objects. In the function I will be able to loop through the array, access a property and use that property. Like this: Variable that I will pass to the function will look like this: [{"id":28,"Title":"Sweden"}, {"id":56,"Title":"USA"}, {"id":89,"Title":"England"}] function test(my...

Sending JSON(jQuery) to PHP and decoding it

I can't for the life of me figure out what I'm doing wrong. It seems like it should be simple because I can't find anyone else with this issue but I can't figure out to send basic data via javascript(jQuery) to PHP and decode it. For the sake of simplicity, this is what I have: JAVASCRIPT var json_data = { "name" : "john doe" }; $.a...

JS - Why is this hidden div not showing in IE?

Hello. I've made a page which should show a div when the user clicks on a input text box. The div will contain more information about the required input, etc. The page works fine on FireFox and the div shows, but when using IE the div just doesn't show. It seems like I've tried everything and nothing has worked so far. This is the page. ...

using jQuery to load the body of another HTML document between entries

I'm trying to use jQuery to load the body of another HTML document, which contains our AdSense banner. It should display under each blog entry when in list view. I'm able to get it to load text, even images, but not the banner; the banner is a small script. Here is the website we are working with: http://neverknowtech.com/data/ (that's ...

Listing down stored records localStorage | Google Chrome Extensions

How do I get to list down the stored records in the for loop? Basically I want it to list down the records like this: '<div id="record_' + number + '">' + localstorage value + '</div>' The number in the class should add 1 every record, e.g. 1, 2, 3, 4 every record it lists down, and so on. The localstorage value should show the loc...

Combining javascripts into a single file

Having read up recently on yahoo's web optimisation tips and using YSlow I've implemented a few of their ideas on one of my sites http://www.gwynfryncottages.com you can see the file here http://www.gwynfryncottages.com/js/gw-custom.js. While this technique seems to work perfectly on most occasions, and really does speed up the site, b...

Firefox XUL toolbar with javascript to IE?

Hi, I have developed a Firefox toolbar in XUL, which uses javascript to manipulate the DOM. I'd like to export this to IE. I know that IE doesn't support XUL, but wonder: (1) is there an easy way to use the existing javascript code for the IE toolbar as well? (2) is there a IE installer that easily creates all necessary registry val...

Why is my array losing its contents when I refresh the page?

I have created an: var checkboxFarm = new Array(); then I want to record a checkbox status in that array, as there are 11 checkboxes. Button.addEventListener("click", function() { rp_farmAtivada(index); }, false); when clicked change the variable in the array: function rp_farmAtivada(index) { checkboxFarm[...

Coding alternative shaded rows?

I want alternative rows in my table to be shaded. what is the best way to do this, javascript, rails? Today, i do a simple <% num % 2%>, but this is such a common operation that i think there should be a smarter way to do it ...

jQuery conflicts with another jQuery library

I am currently trying to implement a jquery slider into a joomla website. I already implemented NoConflict(); so that it doesn't step into joomla. And it works, BUT for another reason wich I do not understand it enters another jquery file called jsloader.js of a plugin I use for picture gallery display. I suppose all the module jquery...

how to execute javascript on server-side?

is there a php library or something? ...

Javascript window resize doesn't work in Safari but does in Firefox

I have this basic javascript code: window.resizeTo(1000,800) set to run when the page loads and it works perfectly in Firefox but not in Safari. Thanks in advance! ...

Suitable data structures for saving files in localStorage (HTML5) ?

It is nice when there isn't a DB to maintain and users to authenticate. My professor has asked me to convert a recent research project of his that uses Bespin and calculates errors made by users in a code editor as part of his research. The goal is to convert from MySQL to using HTML5 localStorage completely. Doesn't seem so hard to do,...

How to access 'private functions' in a singleton from another object inside it.

I am currently trying to create a test suite for my javascript apps. My problem is that, it seems I cannot get access to init() from my utils object, as you can see below: I have my app that follow a singleton pattern: var appModal = function () { var utils = Object.create(moduleUtils); function init(caller, options ) { } ...

How to change a button from another function?

var ButtonFarmAtivada = new Array(); function X() { var tableCol = dom.cn("td"); //cell 0 //create start checkbox button ButtonFarmAtivada[index] = createInputButton("checkbox", index); ButtonFarmAtivada[index].name = "buttonFarmAtivada_"+index; ButtonFarmAtivada[index].checked = GM_getValue("farmAtivada_"+index, true); FM_log(3,"c...

Gooogle Search / Map Api Seperating JS from Html

As my coding revolves only around one function,the function OnLoad() where the map and search is together on this function. However i was tasked to separate the Maps and Search JS and was unable to do so. Is there any tips or tricks to separating them? ...

Possible to get list item (<li>) label with JavaScript?

If I've got a ul with 3 items in it and the list-style-type is set to lower-alpha, I end up with this a. Item 1 b. Item 2 c. Item 3 With jQuery, I can easily get the value of any item you click - "Item 1" if I click the first. But can I get the list item label? In this case a? ...