javascript

Dynamic select box and dynamic DIV, set element as opposed to remove/append

I am creating a dynamic select box, on change a text section will get populated with data. I would rather have the data set to some text as opposed to being append. For example: This function gets called when a select box is changed: function createDetails(...) { var details = document.getElementById("detailsDIV"); var docFr...

Prototype: How to prevent button pushing until response is made

I am using this piece of code to make text button on web page <a href='#' onclick="new Ajax.Updater('history', '/responsesG', {parameters: {name: '%s', port: '%s', profil: '201', action: 'profile'}, insertion: Insertion.Top} ); return false;">Do something</a> since it is costly call I would like to prevent user from multi...

How can I set the focus of a browser tab in IE?

Setfocus() only works on windows, not browser tabs. Any ideas? ...

setInterval/setTimeout return value

Two questions: How is the value returned from setInterval and setTimeout (the ones used to clear the timers) calculated? Is it possible for both the functions to return the same value during runtime? For example: var a = setInterval(fn1, 1000); var b = setTimeout(fn2, 1000); Is it possible for a and b to have the same value? The fi...

Using prevent default to take over spacebar

I have some code like this to take over the space bar's function: $(document).keypress(function (e) { e.preventDefault(); if (e.which == 32) { // func } }); Unfortunately this destroys all key's defaults. This: $(document).keypress(function (e) { if (e.which == 32) { e.preventDefault(); // func } }...

Is it possible to find JavaScript events that are tied to a specific piece of HTML?

I'm working with someone else's code, and I want to be able to see what JavaScript they have tied to a particular button on the page. Is there some way to watch what code is being fired off by clicking the button in FireBug or something? ...

obtain height to position a div in absolute mode

hello everyone, as my last question was answered inmediatly.. i decided to post a new one which is taking all my hair away, XD this is the problem.. i have a design with an absolute positioned div.. which has a transparent png and a simple anchor... just like this. <div class="buyfloat"> <img src="img/buy.png" /> </div> so.. i...

end a setTimeout function before its set time

hi guys, i have a jquery function that when clicked produces a set timeout on making a div visible. however, if another option is selected during the settimeout length, i would like to know how to destroy this function and stoop anything else in it happening. my current code is: $(document).ready(function(){ $('li#contact').click(fu...

JavaScript Regular Expression Email Validation

For the love of God I am not getting this easy code to work! It is always alerting out "null" which means that the string does not match the expression. var pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$"; function isEmailAddress(str) { str = "[email protected]"; alert(str.match(pattern)); return str.match(pattern...

Use ASP.NET Resource strings from within javascript files

How would one get resx resource strings into javascript code stored in a .js file? If your javascript is in a script block in the markup, you can use this syntax: <%$Resources:Resource, FieldName %> and it will parse the resource value in as it renders the page... Unfortunately, that will only be parsed if the javascript appears in...

Is there a quick way in javascript to determine if an ancestor node is positioned absolutely without walking up the entire tree?

I need to determine if an HTML element is nested inside an element that is positioned absolutely. (1)* e.g. I can do this: function hasAbsoluteAncestor(obj){ while(obj != null){ if(window.getComputedStyle(obj,null).position == 'absolute'){ return true; } else { obj = obj.offsetParent; } } return false; } /...

How to run javascript on the server

I'm writing an iPhone app that needs to interact with the Google Maps API, therefore I must user Javascript (please correct me if I'm wrong) to access the results and the route created. Since the Javascript support in native iPhones apps is quite poor and slow, my idea was to ask a remote web server to do the job for me. That server wou...

Getting the final/timed render of a URL.

Hi, I am looking for a way to, give a URL, get the source of a webpage back after the JavaScript has been run on it. For example: I have a webpage with a . On loading the page, some JavaScript populates the div. Viewing the source of the page through a browser will not give the information which is within the div. As far as I know, in...

Could a page display diferrent content if the URL hash changes?

How could a page display different content based on the URL hash? I'm not talking about the browser scrolling down to display the anchored section, but something like JavaScript reacting to that hash and loading different content via AJAX. Is this common or even probable? ...

Hide Image Title Tool Tip Popup on Mouse Rollover or Hover

Hello, I'm hoping I can get this question answered here... I have a client who wants to add a PayPal "Add to Cart" button inside a Lightbox window. I was able to achieve this by placing the PayPal code inside the image title tag. Not sure if this was the best way, but it worked. However, here is my problem... Now when you mouse over...

QUnit with Ajax! QUnit passes the failing tests!

I am looking into QUnit for JavaScript unit testing. I am in a strange situation where I am checking against the value returned from the Ajax call. For the following test I am purposely trying to fail it. // test to check if the persons are returned! test("getPersons", function() { getPersons( func...

Trigger an event on a specific part of an image

I want to trigger an event handler when the user hovers on a particular part of the image, like the center of the image or the right side of the image (area would include, say, about a 100 pixels). I am not using any framework, so this is normal javascript that I am working with. I am not sure if using image maps would work. Can anyone h...

Callbacks in Server-side technologies (like ASP.net)

Why do we need callbacks in ASP.NET or any server side technology? One answer can be, to achieve asynchronous calls. But I am not interested in its technological perspective. Please tell me the philosophical perspective. ...

Best tool to create a full screen slide show from the web

I need to create a slide show of some images that can go full screen so it can be displayed via S-Video out. The software is delivered via the web so a web-based option is needed. The list of images is dynamic, and I would like to show them in order. The list of photos can change while the slideshow is running, and I would like to add...

Save an html page + change all links to point to the right place

Hi - You probably know that IE has this thing where you can save a web page, and it will automatically download the html file and all he image/css/js files that the html file uses. Now there is one problem with this- the links in the html file are not changed. So if I download the html page of example.com, which has an < a href=/hi.ht...