javascript

Why is this regex not causing an error in Javascript?

Hi. I'm a bit confused about different regex formats. The following methods are causing an error. function validateDate(str) { var expr = /^((((0?[1-9]|[12]\d|3[01])[\/](0?[13578]|1[02])[\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\/](0?[13456789]|1[012])[\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\/]0?2[\/]((1[6-9]...

Javascript Object - 'Static Initialization'

Hi, I'm converting some Java code to Javascript, and the Java object has a Static Initialization block that populates two arrays in the object. My understanding is that this initializer runs only once no matter how many objects are created. Can I do such a thing in Javascript? Java code: public final class MyObject { priv...

jQuery solution for content zooming/switching?

I'm designing a page for a kiosk at a local business that displays both a flash solar monitor as well as a slideshow of images of their new green roof but want a way to focus on each of these objects individually, making the one in focus larger in the foreground while having the other smaller and more subtle in the background or on the s...

Can Javascript do this

make this: /*this can't run*/ var o = {first:1}; function f(arg,o){ /* can i do something make this function's this=o */ alert(arg+this.first); } f(2,o); equal this: var o = { first:1, f:function(arg){ alert(arg+first); } } o.f(2); and I know we can use this: f.apply(o,1); but I want to handle all things i...

jquery, div with table is not visible when I call show();

<div id="abclink"> + click here to view </div> <div id="abctable" style="display: none;"> some text here, allot of text </div> So using jquery I try and do: $("#abclink").bind("click", function() { $("#abctable").show(); }); This doesn't work, and I don't know why? ...

How can I detect the browser version with JS?

I need to detect the OS version with JS not just the OS type. Is this possible? ...

Strategy for lazy-loading markers into a Google Maps Javascript API map

I'm building an ASP.NET MVC site where I want to have a Google Maps Javascript API map that shows markers loaded from my backend through AJAX. As I don't want the client to run into memory issues, I want to lazy-load the markers and apply them to Fluster2 to put them into clusters. I think the best way to lazy-load the markers is to add...

HTML5 Files and FileLists path

I am wondering where the file path is stored in a File object in HTML javascript. I used the Webkit DevTools and got this: FileList 0: File fileName: "script.js" fileSize: 71268 name: "script.js" size: 71268 type: "application/x-javascript" __proto__: File length: 1 __proto__: FileList The file name, size and ...

Bookmarklet to open user defined link and make user defined form drop-down box selections

I've written a bookmarlet to open a user defined web link, in this specific case a specific genomic location in the UCSC genome broswer. javascript:d=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);d=d.replace(/%5Cr%5Cn%7C%5Cr%7C%5Cn/g,%22%20,%22);if(...

JavaScript - Sort SELECT options

Using PHP, I scan a directory and list all of the .xml files. Each XML file contains both a "name" element and a "date" element. The "name" element for each XML file is listed as an option in the select list. This works perfectly fine, however, the "date" element in each XML file is different and contains a date format like this: mm/dd...

php variable to know when jquery has loaded?

I know you can get a $_SERVER['HTTP_X_REQUESTED_WITH'] php variable if jquery has loaded. That's great but if you use an iframe then that variable is no longer available. Is there a way to detect if jquery has loaded and give php a varaible in an iframe? I don't want to load a header or footer if jquery has loaded 100% but otherwise put ...

Are there any Javascript graphics libraries that support visio-like diagram creation and editing?

I am thinking about creating a website that as part of its functionality will allow users to create visio-style diagrams. Are there any Javascript libraries/frameworks that already provide this functionality? Or libraries/frameworks for other in-browser technologies such as flash, silverlight etc? I know there are lots of graphic libr...

How do I view an JavaScript object in IE8's Developer Tools?

Hi All, How do I view a Javascript object in IE8's Developer Tools? In WebKit and Firebug, I can fire a command at the console which returns an object and it'll show me a tree of the object that I can navigate. In Internet Explorer, all I get is: >>getSelection(); {...} Is there a way to get a similar tree view in IE8's Developer Too...

Facebook like status url detection

I am wondering if there is a script similar to the facebook status update thing, What I mean, is when for ex. I paste a youtube/other video site/image/link it automatically detects the contents of the page and associates an embed code with it (if its a video).. So I'm wondering if there is a ready script that has a large database of web...

javascript: how to remove element on title

Hi everyone, As the title, how can I remove a div on the html title using javascript or jquery framework? I know it sounds weird but currently I'm working on a CMS template and the generate title has around the title <title><div id="title">Title of the page</div></title> Any help appreciated ...

Prevent "title" attribute of parent element from causing a browser flyover

The good browsers all work such that an empty "title" attribute for an element means, "don't bother to show a title flyover here". That makes sense, as a little white flyover with nothing in it (edit or nothing but a space character) is, for most people, completely useless. The designers of IE do not agree. My problem is that I've go...

How to use a JSON literal string ?

Since the JSON format specifies that single quotes should not be escaped, most libraries (or even the native JSON parser) will fail if you have an escaped single quote in it. Now this usually is not a problem since most of the time you do an XHR that fetches some data formatted as JSON and you use the responseText which contains your JSO...

jQuery and Native JavaScript Array - error

var tmpANArray = []; for (var i in associatedPpl) { tmpANArray.push(associatedPpl[i]); } alert('about to call toJSON on AssociatedPpl'); alert(tmpANArray); // the next line fails because $.toJSON is getting fed a function var jsonEncodedAssociatedPpl = $.toJSON(tmpANArray); What part of JavaScript/jQuery am I missing? UPDATE The J...

Javascript: Hide Popup With Cordinates

Hi all! My problem: For example: I have a link, when I click on it a popup div is shown, and when I click on the link again then closes the popup, that's ok, but how can I do to close the opened popup box when I click anywhere else outside of the popup. I've searched a lot and I found some solutions, but those weren't enough good to me...

programmatically firing a click handler

I'm using dojo. I've got something like this: <a id="fooBar" onclick="foo();bar();">Foo then Bar</a> I want to trigger fooBar's click handler from another button. Something like: <a onclick="dojo.query('#fooBar')[0].click()">Do FooBar</a> Can I do that? ...