javascript

Is it possible to declare argument types in javascript?

I am crippled without auto-completion, and when I declare a function that takes 'objects' as arguments instead of the actual types, of course auto-completion cannot work. Is there some way to do this? I suspect the answer is 'no' - in which case, how do you manage without auto-completion? ...

Dynamically selecting colors using php or javascript

hi everyone, can anyone pls give sugessions on how to write the script for selecting a color in a live page so that the selected color apply to whole page.can any one pls provide me a sample scripts for dis. ...

Why does $('#id') return true if id doesn't exist?

I always wondered why jQuery returns true if I'm trying to find elements by id selector that doesnt exist in the DOM structure. Like this: <div id="one">one</div> <script> console.log( !!$('#one') ) // prints true console.log( !!$('#two') ) // is also true! (empty jQuery object) console.log( !!document.getElementById('two'...

When to use JavaScript template engines?

Here is an example of JavaScript template from Ben Nadel's demo single page long-lived AJAX application taken from: [source] <script id="contact-list-item-template" type="application/template"> <li class="contact clear-fix"> <div class="summary"> <a class="name">${name}</a> </div> ...

testing source application in qooxdoo

I began to use Qooxdoo the last month so i've got very little experience in its usage. I need to create a test application like the testrunner on the Qooxdoo website, but i need to do tests inside my application environment. I followed these steps: Created the application Compiled the source version with generate.py source Create the t...

What is the >> operator / operand / modifier do?

I'm reviewing some javascript code and the programmer uses >> in a few places. I tried to search on google but couldn't find what this operand / operator does. So here I be. Code example below: var triplet=(((binarray[i>>2]>>8*(i%4))&0xFF)<<16)|(((binarray[i+1>>2]>>8*((i+1)%4))&0xFF)<<8)|((binarray[i+2>>2]>>8*((i+2)%4))&0xFF); ...

Posting screen width using jQuery

Using this code var sw = window.screen.width; $.post("http://www.example.com/track.php", {result: sw }, "html"); and $_SERVER['result']; in the server I'm trying to get the sreen width but it does not work. It is something wrong with the "result". I'm new in Javascript and jQuery... http://api.jquery.com/jQuery.post/ ...

What are the best cursor (mouse) tracking applications for web sites?

What are the best cursor (mouse) tracking Javascript applications for web sites? To be stored in a database... ...

jQuery 1.3 vs 1.4 (Performance)

jQuery 1.4 released recently and the new website shows some performance charts where 1.4 is clearly better, but has someone already done an analysis of overall performance improvement of 1.4 vs 1.3? If not, how do I profile both on my sites/pages, are there any tools? Can't wait to find out how fast is 1.4 compared to the previous versi...

How to set html button as default for ASP.Net form?

Well, I'm trying to make ASP.NET urls looking user-friendly, like it was explained in this question. So I created an ASP.Net form, and placed asp:textbox and asp:button on it. Also I set onclientclick attribute to call JS function which navigates to smart URL by setting windows.location.href. In Firefox it works well but in IE and Opera ...

Greasemonkey @require jQuery not working "Component not available"

I've seen the other question on here about loading jQuery in a Greasemonkey. Having tried that method, with this require statement inside my ==UserScript== tags: // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js I still get the following error message in Firefox's error console: Error: Component is not availa...

Selecting + dragging the contents of a div or textarea

Hi folks, I want to select the contents of a DIV (like highlight when you click and drag) when the user clicks on a button. The (hidden) div contains text that needs to be dragged to a 3rd party app outside the browser as input. In other words: I want to simulate the user selecting the contents of a textarea, click and dragging it to an...

Tracking outgoing links with Javascript and PHP

I have tryed it using jQuery but it is not working. <script> $("a").click(function () { $.post("http://www.example.com/trackol.php", {result: "click" }, "html"); }); </script> <a href="http://www.google.com"&gt;out&lt;/a&gt; ...

Safely 'print' raw html code in a textarea to use with CKeditor?

Which character do I need to replace to safely 'print' raw HTML code from a database in a textarea, so I can edit this with CKeditor? Or is there another existing preferred method of getting data into a CKeditor textarea? (e.g. AJAX) ...

Where to find on-hover or on-select dictionaries for web pages?

I would like to add to my site a on-hover/on-select dictionary. What are they usually called, so I can search on the web? I am thinking in a piece of javascript code that detects which word the mouse is currently hovering/selecting and after some time it shows a baloon with the hovered word definition. ...

Make div appear with jQuery

Hello, I have a div that is hidden and being declared this way: <div id="divLogin" style="visibility:hidden;"> My idea is to use jquery to make it slide in so I created this code: $("btEnviarAcesso").click(function () { $("divLogin").slideToggle("slow"); }); but it is not working... Does someone have any ideia why?? ...

Javascript or Apache timeouts for ending a web request?

hey all, I have a little tag on my blog pages to help me track user stats... which then echo's out javacsript to the browser. This script tends to hang sometimes, maybe my server is overloaded or some other issue. Is there a way to terminate the loading of this script after 2 seconds lets say? or configure my apache at myothersite.com...

How can i pass $.ajax object to another function?

This function will be using in general ajax calss: function f_AjaxFunction(_param) { var objectWillReturn; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: 'WS/wsGenral.asmx/f_QueryAndGetResultAsJson', data: "{_sParam:'" + _param + "'}", dataType: "json", ...

PHP: how to serve right content-type (depending on file extension?)?

I'm using the scripts below to gzip some CSS and JS files. It works nice - except for serving JS files with the wrong content-type (and not the appropriate application/x-javascript). How could I improve the PHP code in order to serve the right content-type? Thanks! .htaccess: AddHandler application/x-httpd-php .css .js php_value auto_p...

Ajax concurrency

I have a web application where there is a timer that is constantly counting down. Meanwhile, the client frequently checks with the server to see if more time has been added to the timer. The code looks something like this: function tick() { // This function is called once every second time -= 1; redisplay(time); }; function ...