javascript

JavaScript or Jquery event handlers for "ctrl"/"shift" + mouse left button click

Is it possible to handle such events as: "ctrl" + mouse left button click; "shift" + mouse left button click; "alt" + mouse left button click by using JavaScript/jquery(or other framework). If it is possible, please give a code example for it. ...

Javascript: is using 'var' to declare variables optional?

Is "var" optional? myObj = 1; same as ? var myObj = 1; I found they both work from my test, I assume var is optional? ...

which is the best library(python or javascipt) to save the google-maps info(kml file)..

i want to save the user's map info ,and then loading them when they need. i use python(pinax) and jquery , thanks ...

jQuery wrap code after x number of elements

Hi all - I have a UL that contain any number of LIs. I am trying to create some jQuery code that will parse the original UL and wrap a UL and another LI after every 5 of the original LIs. Starting HTML: <ul id="original_ul"> <li class="original_li">..</li> <li>..</li> <li>..</li> <li>..</li> <li>..</li> <li>..</...

how to fetch a url with javascript/jquery?

i need to fetch a url with javascript/jquery and not php. i've read that you could do that if you got a php proxy, but that means that it is still going through php. cause then it's still the ip of the server that is fetching it. could one fetch the url entirely with only front-end, and thus fetch it with the client's ip? ...

How can I destroy sessions if user closes the browser window or navigates away from page in php?

I have some sessions that are saved. I want to destroy all the sessions if the user closes the browser window or a single tab or navigates away from the page. Is there any way I can do this? ...

valueOf() vs. toString() in Javascript

In Javascript every object has a valueOf() and toString() method. I would have thought that the toString() method got invoked whenever a string conversion is called for, but apparently it is trumped by valueOf(). For example, the code var x = {toString: function() {return "foo"; }, valueOf: function() {return 42; }}; window.c...

What objects would get defined in a Bridge scoring app (Javascript)

I'm writing a Bridge (card game) scoring application as practice in javascript, and am looking for suggestions on how to set up my objects. I'm pretty new to OO in general, and would love a survey of how and why people would structure a program to do this (the "survey" begets the CW mark. Additionally, I'll happily close this if it's out...

document.getElementById() returns null when using mozrepl (but not in firebug)

I'm trying to use the mozrepl Firefox extension to give me a Javascript REPL from within emacs. I think I've got it set up correctly. I can interact with the REPL from emacs and can explore the document pretty much as described in the tutorial pages. The problem comes when I try to do something really simple, like get a context to a can...

How can I duplicate the UI functionality of Google Fastflip?

Trying to get the same functionality as Google FastFlip. Not just with the thumbnails, but even for the larger images too. Notice how when you click on a story, you see the main story front and center, and you see smaller half-screens of previous and next stories. How can I get that functionality? Is there a plugin for one of the JS fr...

storing/retrieving data for graph with long continuous stretches

i have a large 2-dimensional data set which i would like to graph. the graph is displayed in a browser and the data is retrieved via ajax. long stretches of this graph will be continuous - e.g., for x=0 through x=1000, y=9, then for x=1001 through x=1100, y=80, etc. the approach i'm considering is to send (from the server) and store (i...

Is It Possible To Use Javascript/CSS To Swap Style Sheets When A Mobile Device Rotates?

I am working on a site that must be designed with mobile accessibility in mind. As part of our brainstorming, we wondered whether it's possible to detect, for a mobile browser (i.e. Mobile Safari or the Android browser), when the viewing device has changed orientation, and to use that as a trigger to change page content? As the title o...

Is it possible to navigate swf file using javascript/jquery?

When we open plain swf in browser, we are able to control the swf file by right clicking, the available control are: zoom in, zoom out, quality, rewind (previous frame), forward (next frame), and print. Is it possible to trigger those control using javascript especially jquery? ...

Trouble with javascript subtraction

I'm working on a simple subtraction problem, but unfortunately it keeps returning NaN Here is the function function subtraction(a, b) { var regexp = /[$][,]/g; a = a.replace(regexp, ""); b = b.replace(regexp, ""); var _a = parseFloat(a); var _b = parseFloat(b); return _a - _b; ...

Should a "script" tag be allowed to remove itself?

We've been having a discussion at our workplace on this with some for and some against the behavior. Wanted to hear views from you guys : <html> <body> <div> Test! <script> document.body.removeChild(document.getElementsByTagName('div')[0]); </script> </div> </body> </html> Should the above script work and do what it's supposed to do?...

Generating Javascript from PHP?

Are there any libraries or tools specifically designed to help PHP programmers write Javascript? Essentially, converting the PHP logic into Javascript logic. For instance: $document = new Document($html); $myFoo = $document->getElementById("foo"); $myFoo->value = "Hello World"; Being converted into the following output: var myFoo = d...

Maintain aspect ratio on browser window resize?

I have a simple page with images, and when the user clicks the image, it opens up a new browser window with the image filling the area. I have the css set on the new window so that the image height and width are both 100% (and overflow is set to hidden) so that the window can be resized. But what I need is for the window to maintain asp...

How to hide the scrollbar using JavaScript (jQuery)

How can the scrollbar be hidden? I want to do this because the scrollbar is not nice. overflow:hidden is not useful, because my div element has many other elements. So setting overflow does not solve my problem. ...

javascript alarmclock script

it's work only once. at second button click, occured nothing. if I change budilnik variable at i_budilnik or var budilnik, occured nothing at first and other clicks! Where is the problem? <div><form name="alert"><input type="text" name="hour" /><input type="text" name="min"/><input type="button" value="ok" onclick="budilnik(this.form)...

Get contents of local folder in javascript (or ASP.NET VB)

Is it possible for a webpage to popup a open folder dialog, ask the user to select a folder, then show the contents of that folder in a list(or something) in the webpage. It won't write to the files, only read them. The webpage is hosted remotely. Jonathan ...