javascript

ASP.NET and Javascript DOM manipulation

I have an aspx page with a set of controls. A small JS script written on top of jQuery allows the user to drag "li" elements from one list to another. What I would like now is for my C# code to be able to figure out which items the user has placed in which list after the page is posted back to the server. Does anyone know how I can d...

Firefox does not support JavaScript (form validation) but IE fully support.

this is my code: function validateFormOnSubmit2(theForm) { var reason = ""; reason += validateState(theForm.state); if (reason != "") { alert("State field need correction:\n" + reason); return false; } return true; } function validateState(fld) { var error = ""; if (fld.value == "") { error = ...

Best practice for allowing users to embed content

Hey guys, I know there are a lot of services out there that allow users to embed created forms on their websites, and I was curious about the best practices for creating such a service. Two obvious methods are iframes and div replacement with javascript. What are the advantages / disadvantages of both, and are there any other alternat...

Javascript: How do I retain a reference to a request initiator in a handler?

I'm not a Javascript person normally, but I've been diving in, reading Douglas Crockford's book, and writing some trivial, useful tidbits as Chrome extensions and Node.js (note that this question isn't about either of them). Right now, I'm trying to figure out how to retain a reference to an object that's initiating an AJAX request, th...

javascript timer page up and down won't go to bottom of page

I have a timer script which scrolls up and down and repositions the page to the top every 10 seconds and back down every 5 seconds. My problem is I can't get it to scroll all the way down. <script language="JavaScript" type="text/javascript"> // Configure refresh interval (in seconds) var refreshinterval=300 // Shall the coundown b...

Leading zero when subtracting one time from another javascript

function setValue() { var startTime = document.getElementById('ToilA'); var endTime = document.getElementById('EndHours'); startTime = startTime.value.split(":"); var startHour = parseInt(startTime[0], 10); var startMinutes = parseInt(startTime[1], 10); endTime = endTime.value.split(":"); var endHour = parseInt(endTime[0], 10); va...

Javascript: Show/Hide multiple elements by name

I need to show/hide multiple elements with the same name when another element is clicked, like <span name="showhide" value="one" id="button">Click to Hide One</span> <span name="showhide" value="two" id="button">Click to Hide Two</span> <span name="showhide" value="shoe" id="button">Click to Hide shoe</span> would hide the elements with ...

jquery tooltip showing a hidden div element?

I am trying to have tooltip for my personal website http://www.stacked.in. when I move the mouse on the link, I want to have tooltip displayed. Tooltip display content is already available inside the html page as a div element, but it is hidden. I want the tool-tip to be displayed only when I move the mouse over the link. I use jquery an...

How to get timezone before postback

I am making a page that accepts post data from any number of pages that I cannot change, access, or in any way control. I need, in one way or another, to get the timezone of the user. I know, ideally the posting page would do this, but I cannot access these pages. I've read other answers on this site and come up with 2 almost, but not ...

Ajax call when clicking a radio button sometimes alternates between being instant to taking ~2 sec

There are 2 radio buttons. Depending on which one you click, the drop down box will load that set of data. Depending on the first one I click, that one will take about 1-2 secs to load, while the other loads instantly. Even click back and forth. I was wondering why, and how I might be able to have it stop loading instantly (weird, I know...

Updating image data using putImageData on a resized canvas element

I have a static image (a png) that I'm drawing on a canvas element using drawImage. var _canvas = null; var _context = null; var _curImageData; function copyImageToCanvas(aImg) { _canvas = document.getElementById("canvas"); var w = aImg.naturalWidth; var h = aImg.naturalHeight; _canvas.width = w; _canvas.height = h; _conte...

jQuery callback into non-jQuery parent object

See this code: var MyObject = new function() { this.tos = new Array(); this.show = function() { this.clearTimeouts(); $("#divExample").slideDown(null,function() { MyObject.tos[MyObject.tos.length] = setTimeout(function(){MyObject.doSomething();} , 1800); }); return; }; this.doSomething = function...

plotting negative numbers with flot / jquery

I know Im missing something retarded here... All Im trying to do is graph f(x) = 2500 for a range of x from -75 to 75. This should make a horizontal line. Right now, I think its a misunderstanding on my part of some specifics of arrays. It starts at 0 and goes to 75 fine, it does not graph lower than 0. (I get half the line) for(x = -75...

Making resizable image backgrounds with HTML, CSS, and Javascript

I'm trying to create an image object or canvas object that will resize based on the window dimensions, but keep the aspect ratio. Is this possible? I know that with canvas, you can maintain bicubic scaling, but is it possible to have the image scale on the window resize while maintaining the aspect ratio? ...

Appending elements to DOM in a loop structure.

Dear experts, Once the page has been loaded, I would like to append an additional element for each existing elements on the page. I tried something like this: var divs=document.getElementsByTagName('div'); for(i=0;i<divs.length;i++){ newDiv=document.createElement('div'); divs[i].appendChild(newDiv); } ...

Trouble with Firefox and jQuery blockUI

I have been building a site for learning purposes and have recently added pagination which also through Ajax. Well, I want to use blockUI for the beforesend: function for Ajax to show a "processing" box over the div that will have its content updated. It seems I can get it working fine for Internet Explorer, but when I try to use Firefox...

Why does IE throw an "access denied" error when trying to access any property of a popup window?

I have created a popup window (something) like this: var win; function popup() { if (win) { win.close(); win = null; } win = window.open(...); } That exact code, in a simple .html file, works just fine. However it causes problems in our web app. IE always throws an "access denied" exception when trying to access most any...

DRY programming with jquery

Posting as a jquery newbie. I am sure there must be a way to condense the code below in a DRY fashion. Essentially this is just a show/hide that is applied to multiple elements on a page, all using the same template and naming conventions: $("#homelink1").hover( function() { $("#poptext1").show(); }, function() { $("#poptext1")....

How to use JQuery Slider control without loading JQuery ?

I want a use a Dual Slider (Range) HTML control, similar to the JQuery dual Slider, without having to load a huge JavaScript framework just to use it. Does such a dual slider control exist, that is light weight (filesize) and doesn't require me loading any JavaScript frameworks? ...

Google Maps Api v3 trigger issue, external link hit info window

So my code looks like this, multiple markers: var m1 = new google.maps.Marker( new google.maps.LatLng(35.2602340, -93.7939480), {icon:tinyIcon,bouncy:1} ); google.maps.Event.addListener(m1, "click", function() { m1.openInfoWindowHtml( '1<br />test,TX' ); }); map.addOverlay(m1); var m2 = new google.maps.Marker( ...