javascript

javascript closures and function placement

Does the placement of a function have an effect on the performance of closures within scope? If so, where is the optimal place to put these functions? If not, is the implied association by closure enough reason to place a function in another place logically? For instance, if foo does not rely on the value of localState, does the fact ...

How can I define an accesskey for an invisible HTML element

I have a <button> with an accesskey assgined to it. The accesskey works fine as long as the button is visible, but when I set display: none or visibility: hidden, the accesskey no longer works. Also tried without success: Use a different element type: a, input (various types, even typeless). Assign the accesskey to a label that wraps ...

Display accurate local time on web site?

I've been asked to display the 'correct' time on our website which I frankly feel is rather pointless as 'correct' can be interpretted in such a variety of ways. Our current method definately results in an inaccurate time as it uses a server control rendering JavaScript that runs onload using the datetime from the server as a parameter ...

Submit multiple forms on one page ( ASP )

I have a table where each row will represent a form. There could be over 25 rows in the table. I need to post the rows that have a checkbox checked and get the results and display success of fail. I am posting to a site that I do not have any control over and they take one rows worth of data. I tried this using IFrames and it seemed to...

How can I browse the local network from a web client using C#?

Our web client needs a way to browse the local network and select location for file storage. This will then be returned to the webpage as a UNC name. On a native client this easily accomplished by using Shell32 functions. I've looked at ASP FileUpload, but that returns the file vs. a specific directory. EDIT: Another option would be...

Embedded browser with iframe

I am writing a web application that will run in kiosk mode on a touch screen. I am currently only targeting it for running on Firefox 3. A few of the use cases I have need to visit external sites. I wish to do so with an embedded browser, which I'm tackling with the help of an <iframe>. I need back/forward buttons for the embedded home p...

Display JSON/YAML hierarchy as a tree in HTML?

I have YAML data that looks sort of like this, but ~150k of it: --- all: foo: 1025 bar: baz: 37628 quux: a: 179 b: 7 ...or the same thing in JSON: {"all":{"bar":{"baz":"37628","quux":{"a":"179","b":"7"}},"foo":"1025"}} I want to present this content in an expandable JavaScripty HTML tree view (examples: 1, 2...

Propagate Permissions to Javascript

I'm debating the best way to propagate fairly complex permissions from the server to an AJAX application, and I'm not sure the best approach to take. Essentially, I want my permissions to be defined so I can request a whole set of permissions in one shot, and adjust the UI as appropriate (the UI changes can be as low level as disabling ...

Can I comment a JSON file?

Can I comment a JSON file? If so, how? ...

Internet Explorer 7 Ajax links only load once

I'm writing an application and I'm trying to tie simple AJAX functionality in. It works well in Mozilla Firefox, but there's an interesting bug in Internet Explorer: Each of the links can only be clicked once. The browser must be completely restarted, simply reloading the page won't work. I've written a very simple example application th...

What's the difference between JavaScript and Java?

What's the difference between JavaScript and Java? ...

Setting OnLoad event for newly opened window in IE6

Hey folks- I need to set the onload attribute for a newly popped-up window. The following code works for Firefox: <a onclick="printwindow=window.open('www.google.com');printwindow.document.body.onload=self.print();return false;" href='www.google.com'> However, when I try this in IE, I get an error - "printwindow.document.body null or ...

jQuery ancestors using jQuery objects

I'd like to check ancestry using two jQuery objects. They don't have IDs, and are only going to be available as jQuery objects (or DOM nodes if you called get()). jQuery's is() only works with expressions, so this code would be ideal but will not work: var someDiv = $('#div'); $('a').click(function() { if ($(this).parents().is(som...

Google Analytics Domain Tracking API _link() method

Has anyone else had any problems using google's Domain Tracking API, I am specifically talking about the _link() method. The documentation is here The example provided shows that the _link() method should be used in the onclick event like this: <a href="http://www.newsite.com" onclick="pageTracker._link('http://www.newsite.com');retur...

How can I tell if my page is set as the user's homepage?

Is there any way I can detect when my page has been set as the user's homepage in their browser? I'm most interested in something in javascript, but I'd be happy to hear about other approaches as well. Edit: I'm not looking for anything sneaky. I'm wondering if there is anything that is explicitly allowed through the browsers to find ...

How does XUL (specifically firefox) statusbar positioning work?

When I go to create my status bar overlay, I note that I can include a position attribute. I want to be able to dynamically change this attribute. Near as I can tell, just using JavaScript to find the element and change the position attribute doesn't move the status bar panel around on the status bar. Any suggestions as to how to accomp...

Get the ASP.NET form name

I'm looking for a way to get the name of the main HTML form so I can submit it from JavaScript. The reason I can just set the name of the form is because the JavaScript is on a User Control that could get added to many different sites with different form names. Thanks. ...

What is the best way of scrolling the browser window for expanding elements?

What I want to do is scroll down the window when I expand elements in my page. The effect I am trying to achieve is like the Stack Overflow comments. If it expands beyond the page, it scrolls down to fit all the comments in the window. What is the best way of doing this? Edit: I am using JQuery. ...

What is the difference between the different methods of putting javascript in an <a>

I have seen the following methods of putting javascript in an <a> tag: function DoSomething() { ... return false; } 1: <a href="javascript:;" onClick="return DoSomething();">link</a> 2: <a href="javascript:return DoSomething();">link</a> 3: <a href="javascript:void(0);" onClick="return DoSomething();">link</a> 4: <a href="#" onClick="re...

How do I round a number in javascript?

Hey all. While working on a project, I came across a js-script created by a former employee that basically creates a report in the form of Name : Value Name2 : Value2 etc... Problem for me though, is that the values can sometimes be floats (with different precision), integers, or even in the form "2.20011E+17" What I outputted thoug...