javascript

Drag and drop image into a web form

We have a web page (HTML javascript and PHP mostly) that allows a user to upload an image. We have the normal browse button, and it works fine. However, we want to add the functionality to drag and drop an image into the text field instead. gmail allows you to do this in their mail app, so it's possible. The only way we've thought of to...

Is it possible to determine if a named window is open in JavaScript?

I'm working on an inter-site single-sign-on project and have had a pretty little problem dropped in my lap. When a user logs out of the "parent" site, a particular page needs to be loaded in the popup window containing the "child" site. However, I can't store a reference to the return value of window.open(…), because the user must be a...

Read a specific table column with Prototype

Hi, I need to read all the values of the first column of an HTML table, and I don't want to use DOM methods. I'd like a simpler solution using Prototype or YUI. Note: the table is generated by a grid widget provided by an external team. That's why we cannot be sure of which IDs or Classnames are used. In short I'd like something lik...

Jslint "Line breaking error"

JSLint validation of this snippet 1: function foo() {} 2: 3: foo(1 4: ); 5: 6: foo( 7: ); gives this error: Error: Problem at line 3 character 5: Line breaking error ')'. foo(1 Is this a JSLint bug? ...

jquery/javascript wait for a function to complete

I have script that performs from DOM manipulation to change the way a div looks. The way the application is, when the page loads, the div is rendered in its original state, the function manipulates the DIV. The problem is it renders the original div before rendering the changed div. I tried: //Make div invisible //Call function to cha...

jQuery parents() and parent().parent() only see one level up?

Hi All, I am having some issues with getting the list of parents of an element with jQuery. Perhaps I am missing something, but I have a link inside several nested divs, and am trying to get a list of siblings of the parent's parent. I only seem to be able to go one level up from the link though, so I can't The HTML is as follows: <...

Add days to DateTime using Java Script

How to add days to current DateTime using Java Script. Does Java Script have a built in function like .Net AddDay? ...

is there a javascript (or jquery) short cut for "function(){return false;}"?

It seems like I type "function(){return false;}" some what too frequently too prevent actions from happening... is there a short cut? ...

Why does jQuery has a "window=this" at the very begining and say it would speed up references to window?

When I open jQuery's source code I find this line. var // Will speed up references to window, and allows munging its name. window = this Why and how this line will speed up? ...

Is there a way to simulate a click on an alert in JavaScript?

I have a page with an iframe whose source page is in a separate domain. From time to time, the source page generates an alert. When it does so, it stops what it is doing until the user clicks OK to the alert. What I would like to do is programmatically click OK on this alert so the source page can get back to being useful. Is this possi...

Are there any pitfalls in displaying a "No JavaScript" warning in the following fashion?

I have a webpage that has a comment box that can be toggled by clicking a link (the opening and closing of the box is controlled using JavaScript, specifically JQuery). This box is hidden by default, so naturally, it's impossible to display without the use of JavaScript. I'm not concerned by this fact: the comment box is not a "necessary...

How to figure out what got clicked?

Hi, In jquery, how can I figure out what object was clicked? Is there a way to alert(...) the type of tag? like if it was an <a href> or a <img> etc? ...

How can I define a set of key/values in javascript and both lookup values and iterate the set in order?

I have a set of key/values eg orange=123, banana=4, apple=567. How can I store these key/values in a javascript object such that I can: Retrieve a value via lookup eg set["orange"] should return 123 and, Iterate over the set in the order in which the key/value pairs were added. It seems that for 1. an object literal would be suitabl...

jQuery UI Dialog Throw Errors When Invoked from Greasemonkey

I'm getting this awkward error any time I try and create a dialog from Greasemonkey... I believe it has to do with the limitations of XPCNativeWrapper https://developer.mozilla.org/en/XPCNativeWrapper#Limitations_of_XPCNativeWrapper , though I am not 100% sure. None of the core jQuery methods that I've used have caused errors (append, ...

How to create JavaScript form & User specific action?

I'm looking for help on how to code the following: I want to create a pop-up or Javascript item that allows users to accept the terms of completing an offer for me. Once they have accepted the terms, I would like that offer that they agreed to do to go under the account in a section or tabled labeled "Offers". Please advise on how to c...

show a message box when user close IE

Hello everyone, Any javascript to prompt a message box when a user closes IE? I have tried to find a code sample for quite a while but failed. thanks in advance, George Here is my html code, but it has the following error. Any ideas? To help protect your security, Internet Explorer has restricted this webpage from running scripts or ...

Load page within the page

Hi.. I'm a beginner in PHP and Javascript.. I found a link from http://cmichaelis.whsites.net/whblog/jquery-extjs-1/example2 Inside it there is a code saying : function addPanel(location) { tabpanel.add({ autoLoad: {url: location}, title: 'More Information...', closable:true, autoScroll:true }).show(); }...

I want to disable link button after clicking of it and other enable. toggle enable/ disable between both link buttons using javascript

I want to disable link button after clicking of it & other enable. toggle enable/ disable between both link buttons using javascript <a id="a1" href="page1.aspx">One</a><a id="a2" href="page2.aspx">Two</a> ...

Javascript - form select element open url in new window and submit form

UPDATED - please read further details below original question I have a select form element with various urls, that I want to open in a new window when selected - to do this I have the following code in the element's onchange event: window.open(this.options[this.selectedIndex].value,'_blank'); This works fine. But I also want to submi...

Fitting different images as done in Ted.com

How resizing and fitting different images in a fixed space as done in http://www.ted.com/talks/browse and search results jinni.com. Any leads how this can be done, like with jQuery or with php support something. Thanks ...