javascript

JavaScript Traverse Table Issue

Why does this script bail out (IE) or stick (FF) at the first table cell containing text that it finds? <!html> <head> <script type="text/javascript"> function CheckChildren(obj) { alert(obj.id + ' ' + obj.tagName + ' ' + obj.childNodes.length); for ( i = 0; i < obj.childNodes.length; i++) { Check...

How do I retrieve the textnode of a element without getting descending elements textnodes using Jquery ?

<a href="#">Domain name<span class="value">2</span></a> I would like to retrieve only the text "Domain name". I have tried using $('a').text() but that will also get the text inside the descending SPAN tag. Is there a way to select only the first text node inside the A tag somehow? I can't figure out how. .contents('not:(span)') do...

Get and Set clipboard with JavaScript

I have seen a few threads explaining that Flash can be used to set the clipboard data in Mozilla and Internet Explorer, it's easy, etc. For example http://stackoverflow.com/questions/316508/greasemonkey-javascript-copy-to-clipboard-button However, I would like to read the clipboard and remove certain items before setting it. Is there a...

Dynamically switching XSLT stylesheets in the browser?

The short version: Is it possible to switch to alternate XSL stylesheets in the browser, a la CSS stylesheet switching? The long version: I've always admired the CSS Zen Garden; it excellently showcases the power and flexibility of stylesheets. However, it also shines a light on one of the great weaknesses of CSS: a quick View Source ...

How can I determine the current line number in JavaScript?

Does JavaScript have a mechanism for determining the line number of the currently executing statement (and if so, what is it)? ...

Browser event when downloaded file is saved to disk

I have sensitive files to download to users, and each user is permitted to download a given file exactly once. If the download fails, I want to permit the re-download, but not otherwise. It's not sufficient to rely on logging/processing the file download request at the server - I need to know deterministically when the file is complete...

Recursive function in javascript

Maybe is a trivial problem, i don't know why this function exit from for cycle when it goes on else statement. I need this function to fetch an xml document. function xmlToArray(element){ childs= element.childNodes; if(childs.length != 1){ for(var i=0;i<childs.length;i++){ if(childs[i].hasChildNodes()){ x...

()[]+! in javascript

How is it possible to only use ()[]+! to make javascript code? Ex: http://discogscounter.getfreehosting.co.uk/js-noalnum.php ...

In ECMAScript5, what's the scope of "use strict"?

What scope does the strict mode pragma have in ECMAScript5? "use strict"; I'd like to do this (mainly because JSLint doesn't complain about it): "use strict"; (function () { // my stuff here... }()); But I'm not sure if that would break other code or not. I know that I can do this, which will scope the pragma to the function... ...

HTML code for 3d games!

Hi I want to find some HTML codes for 3d games would you send me some links for it? i have searched a lot but they were not good! thanks ...

jQuery Post to PHP to Redirect?

Hi all, I'm trying to figure out if I can do the following: User submits form to script via jquery post Depending on what was processed, script may or may not return errors If the script did not process any errors (i.e. SUCCESS), I want to redirect to a SUCCESS page I know it's possible to redirect the browser via javascript, but I'...

Keyboard Capture on a Web Page with jQuery

I'm trying to implement a JavaScript component that captures key-inputs and creates a command prompt interface for the web, I don't want to use text-fields It's easy to capture input from keys as follows: $('*').bind( 'keypress', keypressCaptureFunction ) but the bubbling of events is giving me multiple events per key-press, also, us...

Set option value with getElementsByName()

Having this fieldset: <fieldset> <legend>[*death]</legend> <select name=death style="width: 120px"> <option value=Dead>[*died] <option value=NotDead>[*alive] <option value="" selected>- </select> </fieldset> i want to set the [2].value to "-" i have tried without any success: document.getElements...

What steps do you take with VS 2008 to reduce development time with Javascript?

I am seeking your stories on how you have streamlined your client side development with Visual Studio. In particular, it seems that I need to build my site too often in order for changes to pushed down to IE effectively. What shortcuts or tools like FireBug, etc. do you use for your client side development? Do you avoid Visual Studio ...

jquery ajax: headers seem to not be working

hello, i am trying to get the headers of an ajax request i made through jquery $.get(url, function(response, textStatus, headers ) { console.log("Response: %o", response); console.log("TextStatus: %o", textStatus); console.log("Request: %o", headers); } ); this does not seem to be working however: th...

Serialising POST requests jQuery/Javascript

I am working on an application which sends an AJAX POST request (I'm using jQuery currently) every 1500ms. I have noticed that most of the times, these requests succeed within 350-450ms and are sent to the server nicely in the same order as they are generated. However sometimes, one or two requests take nearly 3-4 seconds and they are ...

how do I find the h&w of an image and convert to vars, then use those vars

ok, here's the deal: I'm using a nice plugin I got from http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop/ It's nice and all, but it doesn't solve a particular problem: I'll have users uploading images of differing sizes and aspect ratios, so, here's what they provided: function preview(img, selection) { var scaleX = 160...

How is randomness achieved with Math.random in javascript?

How is randomness achieved with Math.random in javascript? I've made something that picks between around 50 different options randomly. I'm wondering how comfortable I should be with using Math.random to get my randomness. ...

Is there a method I can overload to handle undefined properties in JavaScript?

I'm looking for a way to handle calls to undefined methods and properties in JavaScript. These would be similar to the PHP magic methods __call, __callStatic, __get. An example of the code using this might be: var myObject = {}; myObject.__call = function (called, args) { alert(called); alert(args); return(true); } myOb...

Creating conditional statements for JQuery

Hi folks, I have a very novice question, so apologies if the answer to this is obvious. I am using JQuery to toggle the contents of items based on whether the item has been clicked. I have been able to successfully implement the toggle feature. I now need to have it load with the first two items set to show() with the rest set to hide...