javascript

Submit jQuery UI dialog on <Enter>

I have a jQuery UI dialog box with a form. I would like to simulate a click on one of the dialog's buttons so you don't have to use the mouse or tab over to it. In other words, I want it to act like a regular GUI dialog box where simulates hitting the "OK" button. I assume this might be a simple option with the dialog, but I can't fin...

How to find out what event cause a javascript function to be executed in FireFox?

I'm debugging an old Infragistic grid. One of the javascript functions executes more times than needed. It was coded to be executed when a user clicks a cell in the grid. However, sometimes it runs when on mouse is over the cell. I'd like to know if there's a way to track what event caused this function to run. Multiple executions o...

JavaScript & JSP

Hi there, Firstly, I have done my research and already know that JavaScript = client JSPs = server side. I don't want to waste your time. My situation is that I want to execute JSP code from an event (not from a HTML form). I have a HTML link (<a href="...">XXX</a>), which is NOT within <form> tags; it just an ordinary HTML link. Thro...

Get element using id problem

Hi, I am modifying existing legacy webpages(which i shouldn't modify existing parts but adding) and the webpage uses document.write to write certain html elements. when i use <script type="text/javascript" language="javascript"> var v = document.getElementById('td_date_cal_0'); alert(v); </script> v becomes null and when i c...

Ajax replacment for JavaScript prompt command

The JavaScript prompt command prompt("sometext","defaultvalue"); is a useful way to easily prompt the user to provide a value. But it can't really be a part of any polished web 2.0 application (The dialog looks horrible). Is there any existing component to display a modal dialog that will prompt a user for a value? I can use a pure J...

Problem with KeyPress Javascript function

I call a javascript function from a textbox by using OnKeyPress="clickSearchButton()" Here is my function: function clickSearchButton() { var code = e.keyCode || e.which; var btnSearch = document.getElementById("TopSubBanner1_SearchSite1_btnSearchSite"); if(code == 13); { btnSearch.click(); ...

What is the fastest and safest way to convert ANY type variable to String in JavaScript?

Any thoughts on function that will receive one argument and returns back by string representation of the argument in JavaScript? If the given object implements .toString(), then the function should use it. Otherwise, the function can rely on what the JavaScript implementation offers. So what I come up with is like this. var convert =...

Conditional Operators in Javascript

Is it ok to use conditional operators like a statement like so? (x == y) ? alert("yo!") : alert("meh!"); Or is it more correct to use it to assign a value like so? z = (x == y) ? "yo!" : "meh!"; If it's not incorrect to use it like a statement, then is it possible to add more than one line of code for execution like so? Is it more ...

Setting a custom property with DontEnum

If I create: Object.prototype.count = function() {}; var m = {prop: 1}; for(var i in m) window.status += i + ", "; in the code above i contains also count inherited by its prototype. Now I want to know if there is a way to set a custom property as the flag DontEnum (it is not settable for custom property) so it will not be enumer...

Automatically Resize dojo dijit.Grid widget when it's parent container resizes

I have a dojo Grid widget inside a TitlePane with it's width set to 100%. The TitlePane is in a liquid layout so it's width changes with the browser window size. The problem I am having is that when the parent window expands (or contracts) the grid itself does not change it's width. I can get it to resize itself by calling render() on ...

How does struts 2 includes javascript files in a jsp from their struts.jar?

I've noticed that the javascript client-side validation feature of the struts 2 framework uses a javascript file that comes inside the struts2 JAR file. The javascript file gets included somehow in the JSP page apparently by just using a tag from the framework. If I manage to do this it will be extremely helpful for the many javascript ...

Do you expect Javascript to become widely used outside the browser?

With all the magic you can do in today's browser I wonder if Javascript will become much more prominent on the server side or as a viable alternative for application programming. I ask this because I have poked around with many programming languages except Javascript. Maybe it's time to dive into it, before everybody is wanting and it's ...

load csv file into a javascript file

Is this possible ? I am wanting to pull out a price of a product from the csv file and tie that price to its particular part number. I am doing this for a website and I am learning script programming at the same time, and I am unsure how to do this. The JS file would call the csv file and pull the price and part number out of it. F...

What are persuasive arguments for making the library case?

When making the case for library usage within an application, what arguments lead to the greatest success? How have you successfully helped co-workers see the benefits of library usage? Specifically in the context where: 1. The library is open source. 2. The library is for JavaScript, HTML, CSS. 3. A team of developers has a culture wh...

Ajax (or JSONP) on unload with Safari/Chrome

If you try to send an Ajax request, a JSONP request, or even a window.name request on unload, Safari and Chrome run the code, but the server never sees the request. My theory is the thread of execution never allows the script tag to run before it changes the page. Here is a test page with the JSONP test. This code (and Ajax and window...

Is it possible to disconnect all event handlers in Dojo?

Some code I am working with replaces some HTML elements that have Dojo event listeners with new HTML coming from an AJAX call (using .innerHTML=). I have read that event listeners should be disconnected using the dojo.disconnect(handle) method before they are replaced to prevent memory leaks. Is it possible to derive all handles connect...

How is politico.com inserting a hyperlink into copied text?

If you visit this article on politico.com, highlight some of the article text, then paste that text elsewhere, it will contain a link that says "Read more at: ...". How is this done? Update: This is the JS used, but hard to follow: http://tcr.tynt.com/javascripts/Tracer.js ...

Passing Parameters to jQuery Delete Button Click EventHandler

I have the following jQuery $('#btnDelete').click( function() {//Do the delete here via jquery post}); In my table I have numerous rows with the following <a id="btnDelete">Delete</a> How I do I pass parameters to the click event to post an ID to delete something ...

Incorrectly Embedding a Flash Movie - Guess I'm Guilty

I have tried through another user's suggestion, to use the swfobject methos of embedding Flash. I however, must not be as smart. Below is the monster I have come up with, but no movie plays, and I cannot even distinguish it as a Flash movie when I control+click (Mac)... as if it doesn't even exist. Any direction on how I could fix this...

How does ASP.NET AJAX work when retrieving values from the server?

If I want to call a server function from javascript to retrieve a name of a person from a database (just as an example)... and I went... name = myServices.getName(userId); If I have a script manager with a service reference to a .asmx file that has the web method getName( int userId ) {} then this function should be called properly and...