javascript

How to detect mouse acceleration in javascript?

Hi all, I'm logging the mouse movements in a web app. I'd like to detect the mouse acceleration on a platform (e.g. Windows). Is it possible to do it from javascript, even just in an approximated way? I could ask the user to check their settings with a questionnaire, but it would be much better to detect it automatically. Cheers ...

Aggregating a jQuery object?

I'm authoring a plugin, and the plugin needs to do something like aggregate a set of jQuery objects. How does one do this? For example: <p><a>...</a></p> <p><a>...</a></p> With (function( $ ) { $.fn.myfunc = function( settings ) { }; })(jQuery); Within the context of the plugin invoked with $('p').myfunc(), how would ...

Can I add javascript dynamically to an existing script element

I want to dynamically add javascript to an existing script element something like: var se = document.createElement('script'); se.setAttribute('type', 'text/javascript'); se.innerHTML = 'alert(1)'; document.getElementsByTagName('head').item(0).appendChild(se); The interesting part is se.innerHTML = 'alert(1)'; and if it is valid? If no...

putImageData / Canvas - How do I dump the pixel array in here?

How do I redraw the pixel array after I after I have previously used getImageData? The way that I thought made sense gives me the error: An invalid or illegal string was specified" code: "12 function makeImage(canvasId, background, object) { var canvas = document.getElementById(canvasId); var ctx = canvas.getContext('2d'); ...

Change order in a date with javascript.

Hi, If I have a date like 8/9/2010 in a textbox, how can I easiest set a variable to the value 201098? Thanks in advance. ...

Check for when a user has selected to print using javascript

When a user chooses "File > Print" on a browser such as Firefox or Internet Explorer, or clicks on a link that runs the below javascript window.print(); Is there a way to conditionally check for this mode and disable SOME javascript. I am trying to do this because I have a plugin that adds in its own custom markup for rounded borders...

Xml Traversing with javascript

<links> <osname name="windows xp" links="xyz" /> <osname name="windows 2k" links="xyz" /> </links> <owners name="microsoft"> <os name="windows xp" /> <os name="windows 2k" /> <os name="windows 2003" /> <os name="windows 7" /> </owners> <owners name="microsoft"> <os name="windows xp" /> <os name="windows 95...

Reverting jquery animations back to original css states

I've got a page of elements, each of which, depending on user interaction, may be animated away by the given function: function slideAndFade(id){ $(id).animate({opacity: 'toggle', width: 'toggle'}, 500); } I want to create a reset function that brings all the elements back onto the page. Running all the elements through the toggl...

using access key for browser to underline the first character of all links with access keys

I am trying to figure out how to use the dom to access the access keys of each access keyed link and underline the first character of all of the links on the page when the access key is pressed. i.e. when the person presses alt in IE and Chrome all of the first letters of the links underline letting the person know which key to press. ...

Loop wont add up a running total of form values.

Hi, I am new to Javascript and I am working on an exercise I found online. The problem is that the loop does not pick up the values from the form so the running count never gets updated. Any help is appreciated. Actually one more question, do you have any idea why the values are not getting picked up from the checked input box? The fun...

why are Javascript negative numbers not always true or false?

-1 == true; //false -1 == false //false -1 ? true : false; //true Can anyone explain the above output? I know I could work round this by comparing to 0 but I'm interested. I'd expect at least one of the sloppy equals statements to be true as they do implicit type conversion, and I certainly didn't expect the ternary to co...

problem with IE which removes new lines from $("#content").text()

problem with IE which removes new lines from $("#content").text() HTML Code <div id="content"> <p>hello world</p> <p>this is a paragraph</p> </div> jQuery Code alert($("#content").text()); result (IE) IE removes new line (\n) how can i fix this problem ? hello worldthis is a paragraph result (FF) hello world this is a paragra...

javascript add variable onto end of link

I'm trying to add a variable i created on to the end of one of my links but not sure how to do it? <a href="../../availability/default.aspx?propid=' + myvariable + '">Link</a> Any ideas? Thanks Jamie ...

How Do I Set MIME Type Of A Local File?

I want to be able to set the MIME type of a JavaScript file so that when the file is opened in an internet browser, it is automatically executed. How would I go about doing this? Thank you in advance for your help ...

Simulate click at an anchor tag via javascript

I am trying to change the text in browser's address box by simulating a click on an anchor tag via javascript. This code works just fine in IE, but not in FireFox or Chrome. <script type="text/javascript"> function UpdateQueryString() { var controlRef = document.createElement('a'); controlRef.id = "t1"; contr...

JQuery ajax request inside a function: how to return the value I got?

Hello! I want to write a javascript function, that will make an ajax request to PHP script and returns it's result. That's how it looks: function myjsfunc(some_data) { $.post( "/myscript.php", { some_data: some_data }, function(response) { result = response; ...

Fire an event through an element with a partially transparent background

Hello there, I got stuck with solving a seemingly easy issue. http://jsfiddle.net/HAKvN/3/ By clicking the black box beneath the white bubble you're triggering an event causing an alert to be shown. The white bubble represents a div with the red border indicating its boundaries. The bubble is a background image saved as a PNG file wi...

Get CSS path from Dom element

Hi, I got this function to get a cssPath : var cssPath = function (el) { var path = []; while ( (el.nodeName.toLowerCase() != 'html') return path.join(" > "); } console.log(cssPath(document.getElementsByTagName('a')[123])); But i got something like this : html > body > div#div-id > div.site > div.clearfix > ul.choices >...

Maintain View State After POST

I am creating a site that utilizes the jQuery UI tabs. Whenever the user flips between the tabs, the tab they just left is posted back to the server in order to save the state. One of the tabs in particular is a bit complicated in that, if I select a particular data option, other options need to be disabled. However, because of the POST...

string manipulation in JavaScript

(27.19, 78.01) i have this information in javascript and need in this form. 27.19N , 78.00E if 27.19 is positive then include N after them otherwise S then it can be 27.19S if 78.01 is positive then include E after them otherwise W then it can be 78.01W how i can do this in javascript. ...