javascript

Downsides to Hiding Flash under Overlaying DIVs

Does anyone know of any harm in hiding flash elements that collide with an overlaying DIV? By hiding I mean setting the css visibility to hidden. I understand that it requires a DOM traversal to look for objects and embeds which causes some overhead, but are there any other reasons why people don't do this? This is for sites that don't...

create an array that mimics a clock (javascript)

How would you create an array that contains values, one for each hour, including AM/PM, starting at 12 AM ending on 11 PM in javascript? ...

Tricky Javascript: how to retrieve value from json dict inside array inside dict :)

I've got a json file included in my javascript that defines a variable that looks like this: var places_json = { "count": 13476, "places": [ {"area": "London", "county": "STS", "lat": 52.300151820000004, "lon": -2.36665606, "code": "7567", "id": 1}, {"area": "Sheffield", "county": "STS", "lat": 51.33648680000003, "lon":...

Event listeners in javascript

Does javascript have a sort of event listeners? My scenario: I want to execute Inc function 2 times with different parameters, first execution of Inc and then the second execution, but the second execution must be executed after X seconds (settimeout...) after the first Inc function is completed (all it's iterations, as soon as clear...

Why the subtle cross-browser differences in Event Object.

The following declaration at the window level: var event; // for IE var event = "anything"; // for Chrome will destroy the event object as used here: <div onMouseOver = "alert(event.type);">Mouseover Div</div> Firefox does not seem phased by either declaration. I realize that declaring a variable with the name "eve...

What is the best way to detect IE6 using Javascript?

If browser == IE6{ alert('hi'); } ...

Launching code for Javascript modules

Most of the javascript I work with is UI code - code that attaches additional functionality to the HTML framework of my pages and interacts with various HTML elements. Overall, I'm in favor of breaking UI code into into modules. For example, if I have code that attaches handlers to back/next buttons that implements carousel behavior, i...

Detect WebBrowser Control

Is there any that I could tell if my site is being accessed by an instance of webbrowser control? Would it be possible to identify it by the user agent w/php? or maybe some javascript hack? Or is it 100% identical to the regular IE from the server side? ...

How can I extract tokens from the current URL using JavaScript

Given an URL such as /abc.html#variable1, I want to capture the variable1 part to determine a given user's "virtual page" when working with JavaScript (jQuery). ...

Getting the current script executing file name in javascript

Okay, I've been searching for this for way too long already... I'm trying to find out how I can return the filename of the page that's running an included javascript, from inside that javascript. I can easily do this in PHP using $_SERVER['SCRIPT_FILENAME'], but in Javascript this seems to be a lot harder. Do I really need to substri...

Running a long operation in javascript?

Hi, Is there a good way of performing a long-running operation in javascript? For example, I have a function which may take 2 minutes to run. How do we break up a large operation like this? If I was using java or C, I would perform this task in a background thread. Is there a way to tell the browser to pause execution of the script so i...

Javascript event object is not being populated in event handler function

I have the following code: Html: <tr> <td onclick="ThingClicked()">click me</td> </tr> JS: function ThingClicked(event) { var row = event.currentTarget.parent("tr"); callAnotherDOMManipulatingFunction(row); } For some reason, event.currentTarget is undefined. I tried 'this' but that was undefined aswell. What's going...

jQuery Sanity Check

This is driving me crazy. Please someone tell me I'm not crazy: var constraints = $('.traffic-constraints :input'); console.log(constraints); var i; for (i = 0; i < constraints.length; i++) { if (constraints[i].val() > 0) { //<-------- errorrzz .... the console tells me that i do, in fact, have input objects in my selector (5 of th...

Make javascript reference variable a value variable?

I have a javascript function that goes something like this: function doSomething(me) { var isMeChecked = me.checked; for (i=0;i<=10;i++) { me.checked = !isMeChecked; alert (me.checked); } } I assumed that isMeChecked would remain constant after the first load, but it apparently is a ...

Help needed for non-IE browser compatibility in JavaScript

My code works in IE but not in Firefox. I am trying to get the onmousedown and onmouseup events to work as well as the functions swapFE, swapEF and setUpTranslation in a browser other than IE. I basically have French phrases that appear upon the browser loading and when I click down on a phrase with my mouse they should translate to Eng...

javascript error while creating object

While i am trying to create object like this new Ext.TitleCheckbox () I am getting "not a constructor error" my Object is Ext.TitleCheckbox = { checked:false, constructor : function() { }, getHtml : function (config) { var prop = (!config.checked)?'checkbox-checked':'checkbox-unchecked'; var html = ...

JQuery ajax cross domain call and permission issue

I have this polling script to check if a text file is created on the server. Works great locally, but fails when the file is on a different domain. How would i rewrite this for cross domain support? $.ajax({ url: 'http://blah.mydomain.com/test.txt', type: "GET", success: function(result) { //Success! wind...

How to tell onBlur not to hide the submit button when clicked?

My blur event hides the submit button; but doing that seems to cancel the submit event. I only want to hide when the submit itself wasn't clicked. How can I determine if the focus was lost due to the submit, or due to just wandering off elsewhere? <form action="" method="post"> <textarea id="message" name="message"></textarea> ...

iPhone UIWebView stringFromJavaScript with jQuery

I'm looking for a way to include the jQuery javascript library in my project so I can use [myWebView stringByEvaluatingJavaScriptFromString:a jquery command]; This doesn't work: NSString *jQueryPath = [[NSBundle mainBundle]pathForResource:@"jquery-1.4.1" ofType:@"js"]; NSData *jQueryData = [[NSData alloc] initWithContentsOfFile:jQuer...

How tell when a hidden field is changed

I have some javascript I want to run when a hidden field is changed (via javascript) Is there any way to do this? (or anyway at all to have a field that is not "visible" in asp mvc that I can get a change event on) NOTE: I have confirmed that it is not the fact that the field that is hidden that is the problem, but the fact the field i...