javascript

Fade Background Color on Update Panel

I have a radajaxpanel that is populated with the selected item from a combobox on another update panel. Currently the radajaxpanel is the same background color as the rest of the page. What I'd like to do, is based on it being populated with data, change it's background color to a muted red. I want it to stand out as an action that ha...

How to Create Establish Inheritance Between Objects in JavaScript?

I have the following code that creates two objects (ProfileManager and EmployerManager) where the object EmployerManager is supposed to inherit from the object ProfileManager. However, when I do alert(pm instanceof ProfileManager); it returns false. function ProfileFactory(profileType) { switch(profileType) { case 'employe...

How to get form fields from a specific fieldset?

I'm writing a HTML form that's divided in fieldsets, and I need to get the form fields from a specific fiedset in a function. Currently it's like this: function conta(Fieldset){ var Inputs = Fieldset.getElementsByTagName("input"); var Selects = Fieldset.getElementsByTagName("select"); /* Doing the stuff I need to do ...

How to Open many NEW windows in Javascript?

Hey all, Wondering how to open many new windows with Javascript. I have found plenty of places on the internet that show you how to open a new browser window with Javascript, but I want to open a new UNIQUE window. For Example. I have two links on a page. the user clicks on both links and they are both opened in the same window. I ...

How do I catch jQuery $.getJSON (or $.ajax with datatype set to 'jsonp') error when using JSONP?

Is it possible to catch an error when using JSONP with jQuery? I've tried both the $.getJSON and $.ajax methods but neither will catch the 404 error I'm testing. Here is what I've tried (keep in mind that these all work successfully, but I want to handle the case when it fails): jQuery.ajax({ type: "GET", url: handlerURL, da...

loading javascript dependencies on demand

I'm sure there are different approaches to this problem, and I can think of some. But I'd like to hear other people's opinion on this. To be more specific I've built a widget that allows users to choose their location from a google maps map. This widget is displayed on demand and will probably be used every 1 out of 10 uses of the page w...

strpos is not defined in Chrome?

I am using the functions strpos(string, string) in javascript. In Firefox, Opera and IE the page loads fine, but in Chrome I get the error: Uncaught ReferenceError: strpos is not defined. The page I am working on is http://seniorproject.korykirk.com/0xpi2.php ...

Use of 'prototype' vs. 'this' in Javascript?

What's the difference? var A = function () { this.x = function () { //do something }; }; or var A = function () { }; A.prototype.x = function () { //do something }; ...

Weird Behaviour in jQuery's html method

Any good reason why $("p").html(0) makes all paragraphs empty as opposed to contain the character '0'? Instead of assuming I found a bug in jQuery, it's probably a misunderstanding on my part. ...

Batch file called from Javascript/XPCOM doesn't show command prompt window

I am calling a batch file from Javascript in this fashion: function runBatch(){ var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); exe.initWithPath("C:\\test.bat"); var run = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIPr...

Setting CSS pseudo-class rules from JavaScript

I'm looking for a way to change the CSS rules for pseudo-class selectors (such as :link, :hover, etc.) from JavaScript. So an analogue of the CSS code: a:hover { color: red } in JS. I couldn't find the answer anywhere else; if anyone knows that this is something browsers do not support, that would be a helpful result as well. ...

caching JavaScript files

Which is the best method to make the browser use cached versions of js files (from the serverside)? ...

Alternative to history.go(-1) for FireFox and Safari

Is there an alternative to history.go(-1) for FireFox and Safari. Any Help would be greatly appreciated. ...

How do I determine object that function is a method of?

var A = { x : function () { } }; var b = function (method) { //want to know method's "parent" here }; b(A.x); I want to know that x is defined in A when I call the b(A.x). Is this possible? ...

Javascript Timing

I am trying to create a countdown using javascript. I got some code from here and modified it slighly. <script type="text/javascript"> var c=10; var t; function timedCount() { document.getElementById('txt').value=c; c=c-1; t=setInterval("timedCount()",1000); } function stopCount() { clearInterval(t); } </script> I need to call a c...

document.body.offsetWidth variations for different browsers

document.body.offsetWidth returns the innerwidth value from left hand side to the left side of the vertical scrollbar in firefox. In IE it doesn't, instead it returns from left hand side to the right side of the vertical scrollbar. Does anyone know a sensible way I could make a veriable such as "var = offsetw;" for offsetw to be the scro...

Sample ASP.NET application for Javascript refactoring

Good time of day! I want to write article about what can be done with AJAX client script library for local .NET user group and now I'm lookin for some ASP.NET application which could be used as base for Javascript refactoring sample. Good sample should contain bad code :) Inline Javascript is welcome, so are DRY violations. Hope, ide...

How to draw procedural graphics in Vista Sidebar?

How do I draw procedural graphics in a Vista Sidebar gadget? I have a gadget that collects data over time and I want to draw animating graphs. My current approach is to draw the graph with VML that I update from JScript on a timer tick. Is this the best way? Can I return bitmap bits from a DLL function as the srouce to an <IMG>? E...

Submit form input fields added with javascript

I'm making a simple form to create polls, therefore I want the possibility to add additional input fields in case the user wants more options in the poll. I've made Javascript code that adds a new input field to the form, but the dynamically added input fields are not posted when the form is submitted (I use a standard submit button). ...

Opening a URL in current tab/window from a Firefox Extension

I am creating a Firefox Extension...what would be the javascript to open a URL in the current tab from a menuitem? e.g. in my overlay.xul file i have the following line: <menuitem label="Visit homepage" oncommand="window.location='http://www.somepage.com'"/&gt; but in firefox, when i click on the menu item, it opens the URL but it sc...