javascript

How can I use Javascript dynamic properties so Foo.Bar returns current Date()?

I want to create an object property that re-calculates it's value each time it is called. I took at stab at it: var Foo = { Bar : (function() { return Date(); })() } alert(Foo.Bar); // shows time at object literal Foo was init'd // but need it to show time when it's called It it even possible? ...

how to make a click or double click on a word on a webpage to trigger an event handler?

for a page like http://www.answers.com if the user double clicks on any word in the page, a pop up box will show up and shows the definition for that word. I can think of a way to use DOM scripting to break up all words in the page and then make each of them go under a separate "span" element... but otherwise isn't it true that if all...

can any text on a webpage in a <p> tag or <span> tag be selected programmatically?

can any text on a webpage in a tag or tag be selected programmatically? the input element and textarea element can do that easily, but how about text in other cases? ...

Is a Modal Confirm Box Using JQuery Possible?

Looked around quite a bit, and can't seem to find a JQuery solution (maybe its just a limitation of JavaScript) for this: <a href="somelink.php" onclick="return confirm('Go to somelink.php?');">Click Here</a> In the above example, when a user clicks on the link, it will only go to its href if the user clicks OK in the confirm box....

An FBML skeleton/sandbox page?

Does anyone know where I could find a decent skeleton page or example for creating an all-FBML Facebook app? I've looked all over the official wiki and done a bunch of searches, but I can't find anything reliable. Most of the examples in the wiki are either outdated, broken or oversimplistic. I can do 'Hello World' - now I need the re...

Advantages of prototype based OO over class based

Why is class based OO so popular instead of prototype based OO? Do they teach the latter in schools? Javascript is object based, but people use it mostly functionally, or via frameworks. I know that Sun has had some research on Self, but is there any other source of knowledge; preferably something that is accessible for self learned. I...

Recursive image lazy-load failing in Internet Explorer (6-8)

Problem: I am having trouble implementing a recursive image lazy load in all relevant versions of Internet Explorer. I am using jQuery 1.3.2, and the code that follows works wonderfully on Firefox, Safari, and Chrome. While I would expect that IE6's javascript engine would choke, I am very surprised to find that it does not work at all...

always scroll parent frame with mouse wheel?

I have an iframe main located in indexflash.html which houses the html document indexflash2.html which contains two frames topframe (loads main.html) and bottomframe (loads home.html). Both topframe and bottomframe have scrolling="no". topframe holds the flash navigation controls bottomframe updates with the content to display I wan...

What is the most efficient way to access DOM elements in jQuery?

I am writing a jQuery plugin and I am at the optimization stage. I wonder which of these leads to a quicker script in general, and what sort of mitigating factors are important: Have the script generate lots of classes and ids at the start so finding elements in the dom is easier (quicker too?) later on. Keep classes and ids to a mini...

Problem with jQuery in Internet Explorer 8

I am trying to get my jQuery functions to work on IE8. I am loading the library from google's servers (http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js). The $(function(){}) is never called. Instead, I get an error "Object expected". I opened the developer and ran "typeof $" in the console, and it came up as "undefined". I h...

How do I make Javascript beep?

I want to my web page to beep whenever a user exceeds the maximum character limit of my textarea. ...

firebug net tab 0 request problem

I've step into a problem with firebug, say under the "Net" tab,it always shows "0 request" But I've already "enabled monitor for xxx" Has any one met the same problem before? What can I do to make "Net" tab return to normal again? ...

Suggestions for a JavaScript form builder?

I'm looking to integrate a form builder into a site I'm using, but I'm hoping to find a library that has some or most of the functionality I'm looking for. I'm looking for a library that will give me a nice GUI for building the form, and a JSON (or XML, or similar) output that I can play with in the django backend. I'm planning to use ...

insertRow vs. appendChild

Which method is preferred for adding a row to a table? var tr = tbl.insertRow(-1); or var tr = document.createElement('tr'); tbl.appendChild(tr); ? ...

Regexp to pull input tags out of form

I am trying to extract all the <input > tags out of a <form> tag. I have created a regexp which can identify the entire <form> tag and all the code up to the ending </form> but I cannot figure out how to match all the <input[^>]+> within that. EDIT: The data is a string. I cannot use DOM functions because it's not part of the document. ...

Clear extJS combo value when text is cleared or doesn't match.

How do I get an extJS combo field to clear its 'value' when the display text is blank or doesn't match a list value, i.e. custom text not in the data store? I'm sure there must be something I'm missing, because such a simple feature can't make an otherwise impressive combo useless. ...

jQuery enable/disable show/hide button w/ SELECT options. Get remaining option values

I have a select list which is being populated using the values from a text field. I also have two buttons: an add button which adds the entered value to the select list and a remove button which removes the entered value from the select list. I would like to do the following using jQuery: If the value entered into the text field is NOT...

How to implement displaying the requested named anchor using JQuery / JavaScript / CSS

The page has a container div which holds multiple content divs. Each content div has a named anchor. Only one of the content divs is displayed at a time: Example: <style> .lurk { display: none; } </style> <div class="container"> <div id="c1"> <a name="#c1">One</a> is the loneliest number. </div> <div id="c2" class="lurk"> ...

how do I add an unknown selection of inventory items with a user supplied quantity to a cart?

I'm currently using PHP, JAVASCRIPT, MYSQL, XHTML, CSS to develop my site. Note that solutions are not limited to this but preferred if possible. I have a large MYSQL table of widgets and a page that allows the user to search for a specific widget. Let's say for example the user types the model name for some widget, the search could ...

Constraints on Dijit DateTextBox [Valid days of the week]

Quick question about the Dijit.Form.DateTextBox http://docs.dojocampus.org/dijit/form/DateTextBox This page contains the following: "also validates against developer-provided constraints like min, max, valid days of the week, etc." I can't seem to find documentation allowing me to provide a constraint on the days of the week. For ins...