javascript

What are the performance implications of getElementsByTagName("*")?

Let me start out by saying that I'm not a JavaScript developer so this question may be rather basic. When simulating IE's nonstandard all property I'm using getElementsByTagName("*"), is there a significant performance difference between both methods? ...

How to get JQuery and ASP.Net work together?

Is there any reason why JQuery would not work when used in an ASPX page? We have been trying to get working a simple call like this: $(document).ready(function() { alert("This is SPARTA!!!!!!!!!"); }); An the alert box is never shown. I've had some experience with JS and ASP.Net before with buttons and I know that I have to return...

Simple javascript only working in FireFox

Hello, all.. I created a script that requires selecting a beginning year then only displays years from that Beginning year -> 2009. It's just a startYear to endYear Range selector. The script only works in firefox. I'm LEARNING javascript, so I'm hoping someone can point me into the right direction. Live script can be found at http:/...

How to get ClientID of a TreeNode in a TreeView?

Hi all. How to get ClientID of a TreeNode in a TreeView based on one of its rendered attributes, for example, its title attribute (In my case it's unique) ,using either Server-Side or Client-Side code? I go with this code, but it doesn't work, any suggestion? // Retrieves TreeNode ClientID. function GetTreeNodeID(nodeTitle) ...

How do I add a class to a given element?

Hi, I have a element that already has a class: <div class="someclass"> <img ... id="image1" name="image1" /> </div> Now I want to create a javascript function that will add a class to the div (not replace, but add). How can I do that? ...

Message / confirm dialog

I have a need for a confirm message box from a button click, but only on some conditions. I am cheking two values on the aspx.page, and if one is higher than another, I need a confirmation from the user. Are there any ( simple) way of doing this ? I have been reading about javascript and alert messages, but I cant seem to figure out this...

MSIE Browser height ?

Does anyone know how to get the browser height in IE7+ with javascript? I've seen several ways to get the document or the body height but this is not the same. window.innerHeight works fine in firefox and other browsers, but ie doesnt seem to support it. Thanks ...

Appending a block of javascript to the DOM fails in production - but not in dev

I have an ASP.NET website. Very huge! The latest addition I've made, everything is JavaScript/AJAX enabled. I send HTML and JavaScript code back from the server to the client, and the client will inject the HTML into a DIV - and inject the JavaScript into the DOM using this: $('<script type="text/javascript">' + script + '</sc' + 'rip...

Least intrusive way of securing a web service?

I am maintaining a public website (no authorization required) that uses web services over https to perform various operations. Most of the calls to the web services are invoked from javascript. What has recently occurred to me is that a malicious hacker could, if he/she chose to, call the webservices directly in an attempt to play havo...

Issues with dynamically setting style.overflow in Firefox

I am working on a website for a client, and we have the following requirements: When the browser width is greater than 960px don't show a scroll bar. When the content is wider than the browser but the browser width is greater than 960 don't show the scroll bar If the browser is 960px don't show the scroll bar when it is needed. I hav...

How to organize minification and packaging of css and js files to speed up website?

I am doing speed optimization for my website application. And I found some practises to do that. For example Best Practices for Speeding Up Your Web Site from Yahoo. Among them are: Minify JavaScript and CSS. Minimize number of HTTP Requests by combining several files (css, js) into one. My question is what infrastructure, tools and ...

Block URL using IFrame

I'm loading an external page into an IFRAME, which contains an advertisment that I don't want to let load. Is there a way I can set a URL/domain blacklist for any content inside an IFRAME? ...

suppress keyboard events for input fields

I've defined some global keyboard handling using jQuery's keypress event. Is there a way to suppress these events for input/textarea fields so as not to interfere with typing? I've used some hacks with conditions based on element selectors, but those had a big performance impact as they were fired on every single keypress. (Some of tho...

Need help with jquery/javascript popup window script - getting weird error in internet explorer

Hi I am trying to build a jquery script that will open a new browser window (popup window) for a mail like application (user can double click on mails and they will open in a new window). That is not particular hard. My problem is that I want to keep track of the opened windows, so that if a user double clicks on the same mail item a s...

How do you determine the number of defined elements in an array?

If I have an array in Javascript that has been filled sporadically, how do I determine the number of non-nothing elements in the array? for example: var zipCodes = []; zipCodes[10006] = 'New York, NY'; zipCodes[90210] = 'Los Angeles, CA'; zipCodes.length returns 90,211 here and I really don't want to loop through 90,209 nothings to f...

Textbox in modal pop freeze up sometime on FF

I have a textbox in an Ajax ModalPopUp. Occasionally, whenever the modal is loaded, the textbox freezes in Firefox. It's not happening in Internet Explorer - just Firefox. Any suggestions? ...

Is it possible to determine the users time from a web request?

Is it possible on a web server to determine the users local time and timezone when they sent the request? Could it be done using javascript to capture it and post it back to the server? My company want to track how many users use our site outside of office hours (no I dont really know why either!). Thanks. ...

Break line of code - javascript

Is there a character in JS to break up a line of code to read it as continuous despite being on a new line? Something like.... 1. alert ( "Please Select file 2. \ to delete" ); <-- ? Thanks ...

Event flags in jQuery Flot

I'm hoping to add events to some Google Flot charts, like those seen in Google Finance. After searching some, it looks like someone has started this and has posted a couple images at http://code.google.com/p/flot/wiki/FlotUsage. I can't find any Flot plugins that can do this. Does anyone know of a Flot plugin or example so I can make s...

Determining allowable moves on a grid

Can anyone suggest a suitable way of figuring out a pieces allowable moves on a grid similar to the one in the image below. Assuming piece1 is at position a1 and piece2 is at position c3, how can I figure out which grid squares are allowable moves if piece1 can move (say) 3 squares and piece2 can move 2? I've spent way too long devel...