javascript

How to run JavaScript prior to System.Web.UI.Timer OnTick?

I need a client-side script to confirm that the Timer's OnTick event can proceed. How do I invoke CanContinue() before the Timer1 postback occurs? How do I cancel the postback if user selects Cancel? <%@ Page Language="C#" %> <script runat="server"> protected void Timer1_OnTick(object sender, EventArgs e) { Response...

external interface

I have a calc function in java script that takes three integer parameters, following is the AS3 code import flash.external.ExternalInterface; var para:Array = new Array(); send_btn.addEventListener(MouseEvent.CLICK, clickListener); function clickListener(eventObj:Object ):void { para.push(mean.text); para.push(std.text); p...

Is there any unobtrusive way to hook into jQuery methods for triggers?

I was wondering if there was any unobtrusive way to hook into methods such as attr, data, css, etc and call custom triggers? Ideally, I could do something like this: $(".friend a").bind("attr.changed", changed /* data */, function(e) { alert("The " + changed.attribute + " attribute changed from " + changed.from + " to " + changed.t...

Detect version of Java using JavaScript

Is there a reliable way of detecting what version of Java is installed on the client's machine using JavaScript? ...

How to Cross-Compile Java Source Code to JavaScript?

Given a set of Java source code files, how can I compile them into one or more JavaScript files that can be used with hand-crafted JavaScript? GWT is one option, but every example I've seen so far is aimed at building fancy websites. The simple use case of just converting Java source to Javascript that can be used together with handcraf...

How to determine when an embedded flash object is loaded?

When embedding a flash object, is there a way to determine when it's fully loaded? That's my basic question, but for anyone interested in the details behind it: I am using the (DOMWindow) jQuery plugin. For those not familiar, it's a basic overlay the appears centered on the page, above all other content which is dimmed. Inside of the...

Share Constants Between PHP and JavaScript

I have several constants in a PHP application I'm developing. I've defined a Constants class and the defined the constants as const VAR_NAME = value; in this class. I would like to share these constants between my JavaScript and PHP code. Is there a DRY (Don't Repeat Yourself) mechanism to share them? class Constants { const RESOU...

How can I convert JavaScript code into one big Java string

So I have 1000 lines of javascript. I need to turn it into a Java String so that I can output (via System.out.println or whatever). I'm looking for an online tool to escape all the quotes... something geared toward my specific need would be nice as I don't want other special characters changed. Lines like: var rgx = /(\d+)(\d{3...

What do parentheses surrounding a JavaScript object/function/class declaration mean?

I'm new to both JavaScript and YUI. In YUI library examples, you can find many uses of this construct: (function() { var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event, layout = null, ... })(); I think last couple of parentheses are to execute the function just after the declaration. ... But what about the previou...

Replacing spaces with underscores in JavaScript?

I'm trying to use this code to replace spaces with _, it works for the first space in the string but all the other instances of spaces remain unchanged. Anybody know why? function updateKey() { var key=$("#title").val(); key=key.replace(" ","_"); $("#url_key").val(key); } ...

How can you define how objects are compared in JavaScript

I want to define a JavaScript class, Foo. Foo = function(value){ this.value = value; }; I will create "instances" of my Foo: foo1 = new Foo(1); foo2 = new Foo(1); and I want my instances of Foo to be comparable with each other using the standard == equality operator: foo1 == foo2; // this should be true I can not find ...

Avoid Beep sound when enter keypress in a textbox

Hi, When you create an aspx page as this one: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head runat="server"...

Stop the jQuery autocomplete plugin from forgetting text when the user clicks back

I'm using the jQuery autocomplete plugin to get a list of locations, which works fine. But if the user clicks the browser's back button after submitting the page with the autocomplete textbox, the textbox is empty. If I take the autocomplete off the textbox and submit & click back it remembers the text. Is there a way to stop the auto...

How to detect right mouse click + paste using JavaScript?

Is there a way to detect a right click followed by paste with JavaScript on IE and Firefox ? Update: I decided to use Jquery to do it: $('#controlId').bind('paste', null, function() { // code }); It's not exactly what I was looking (because it gets fired on 'ctrl + v' as well as in 'right click + paste' but I can work around it....

Invoke JavaScript on 3rd party domain

I want to write some javascript and have it call into the DOM for a page I am loading from a 3rd party domain. Can this be done? This looks like what I've already tried using IFRAME but it would seem that doesn't work. Is these some other way like having FF run some javascript directly rather than as part of a page? I know this has all ...

How can I store user feedback related to any part of a web page?

I would like users to be able to double click anywhere on the screen to display a form that allows submission of feedback about that very spot. I can think of 2 solutions: Store X,Y coordinates. Had to rule this out since X,Y coordinates aren't supported on all browsers. Use Jquery to bind an exhaustive list of html entities to a dbl...

Regular expression to remove hostname and port from URL?

I need to write some javascript to strip the hostname:port part from a url, meaning I want to extract the path part only. i.e. I want to write a function getPath(url) such that getPath("http://host:8081/path/to/something") returns "/path/to/something" Can this be done using regular expressions? ...

in JavaScript, which is faster math.abs(value) or value * -1 ??

pretty straightforward but i just want to know which is faster... coz i believe simply multiplying a number by -1 is much faster than calling a predefined method, provided that you are sure that value is negative.. but if that's the case then what is the abs() function for? -simply for making sure that the value returned would always be ...

What's the best way to serialize JavaScript objects to XML ?

I am looking for a best proved way to serialize JavaScript objects to XML, that could be sent to server further in Ajax style. Just googling I've found some options like http://svn.mirekrusin.com/pub/javascript/to_xml/trunk/to_xml.js, but does somebody has proved experience and could recommend any specific library? ...

Jumping to a new html page with JavaScript

In my HTML page, I need to check if Adobe Flash player is installed. If not, I want to automatically jump to another HTML page to tell the user that a Flash player is required. I'm using JavaScript to check if the Flash player is available, using the 'JavaScript Flash detection library'. The body of my html page looks like this : <bod...