javascript

IS it safe to use window.location to query the GET params of a page?

I'm doing a peer review and I've found people using window.location.search to check what paremetes have been sent to a given (search) page. Is it safe to do so? I was thinking that we could probably print the parameters in the HTML output inside a script block and verify the printed variables instead of querying window.location. ...

String length differs from Javascript to Java code

I've got a JSP page with a piece of Javascript validation code which limits to a certain amount of characters on submit. I'm using a <textarea> so I can't simply use a length attribute like in a <input type="text">. I use document.getElementById("text").value.length to get the string length. I'm running Firefox 3.0 on Windows (but I've ...

Overriding !important style using Javascript

Title pretty much sums it up. The external style sheet has the following code: td.EvenRow a{ display: none !important; } I have tried using: element.style.display = "inline"; and element.style.display = "inline !important"; but neither works. Is it possible to override an !important style using javascript. This is for a grea...

Tiny flash in safari - very strange bug!

We have a flash file that in every other browser displays at its correct size (which is something like 1600px) however, in safari it appears tiny. We have also noticed that sometimes when the flash file is not cached it appears at normal size, then after a soft refresh the flash goes tiny again. We are using mootools to include the fla...

Implied string comparison, 0='', but 1='1'

I was debugging something and discovered some strangeness in JavaScript: alert(1=='') ==> false alert(0=='') ==> true alert(-1=='') ==> false It would make sense that an implied string comparison that 0 should = '0'. This is true for all non-zero values, but why not for zero? ...

How to set a focus to an input field in method invoked after onchange() event?

Hello, I've got problems with setting focus to an input field after validating it. I've got 2 fields: from and to. <spring:message code="template.fields.label.from"/>: <mvc:input path="templateFields.selectorRangeFrom" onchange="validateNumber('templateFields.selectorRangeFrom',true)"/> <spring:message code="temp...

Can I interact with Camtasia's player using Javascript?

I have a site where i'm showing 2 "tutorial" videos recorded with Camtasia. They are both "autostart=false" I'm using the combination of an mp4 file, and the movie_controller.swf files. I would like to be able to start a movie through Javascript (i'm assuming this is possible), and also get notified in Javascript when the movie finishe...

Selenium or Watir for Javascript Testing in Rails

We're using RSpec and Cucumber in our Rails apps with good results. Webrat is great for non-AJAX interactions, but we're getting ready to get back into writing tests for our Javascript. Webrat has Selenium support built in, and we've used Selenium before, but I'm curious if anyone has had good results using Watir with Cucumber and what ...

Third party content in custom pop-up window

Taking http://youtube.com, http://justin.tv, http://ustream.tv as examples, is it possible to do the following: Open the third party page in a pop up window Analyze the height and width of the element Resize AND offset the window contents to the size of the element This would be specifically useful when embed is disabled by a parti...

Narrow a list of items as you type with javascript

I am trying to find a plugin or a solid way to narrow a list of items as a user types. Essentially there would be a list that is always visible containing product names for users to scroll through. At the bottom would be a form where you can type in the name of a product. As you type the list is narrowed down. I have been trying to fin...

How do I "refresh" element in DOM?

Hi, I've got an empty DIV element in which I append images by using function createElement("img") and append them with appendChild. So now I've got DIV element full of images. I would like to use one button to clean this DIV and add new images in it simultaneously. Thanks for your help ...

Best way for multiple anchor links to reference a single value that can be used in JavaScript

I have any number of anchor links on a page that need to execute the same block of JavaScript code on click, and that code needs to be associated with one value. There are several of these on each page. I usually use a hidden input to store the value in a one-to-one relationship, but what is the best way to associate several links placed...

Javascript close alert box

I want to be able to close an alert box automatically using javascript after a certain amount of time or on a specific event (i.e. onkeypress). From my research, it doesn't look like that's possible with the built-in alert() function. Is there a way to override it and have control over the dialog box that it opens? Also, I don't want ...

I'm creating and then hiding a jquery time entry using two onready() handlers and it leads to critical errors in IE7 and Firefox

I'm creating a jquery time entry in an onready() handler and hiding it in another onready() handler in jquery. (The reason that the code is being called in two different onread() handlers is that the time entry is being created via a reusable Django widget renderer and hidden via local screen application logic.) The jquery time entry g...

weird IE 7 javascript problem

I have this javascript code working in firefox, chrome, and safari for (idx in all_auction_ids){ alert(all_auction_ids[idx]); }; for the above, instead of getting the values in all_auction_ids, the first value I get is text of type function that looks like a for loop! But if I run the code below, it works fine. for (idx=0;idx<al...

Using JavaScript to manipulate HTML input (checkbox) elements via type instead of name.

I am implementing an HTML form with some checkbox input elements, and I want to have a Select All or DeSelect All button. However, I do not want to rely on the name of the input element (like this example) but rather the type because I have multiple checkbox groups with different names. Is there a way to check and uncheck all checkbox in...

jQuery - Edit a table row inline

Hi, I have a table with arbitrary columns and rows. This fact is irrelevant though really, all I want to do is develop a function that will turn a row (or multiple rows) into a series of text inputs containing the data in the table (or empty if no data in cell). I can't find any examples of people explicitly doing this, so I wondered w...

How to eliminate post-render "flicker"?

I've tried my best to be a purist with my usage of Javascript/Ajax techniques, ensuring that all Ajax-y behavior is an enhancement of base functionality, while the site is also fully functional when Javascript is disabled. However, this causes some problems. In some cases, a DOM node should only be visible when Javascript is enabled in...

What is an easy way to call Asc() and Chr() in JavaScript for Unicode values?

I am not that familiar with Javascript, and am looking for the function that returns the UNICODE value of a character, and given the UNICODE value, returns the string equivalent. I'm sure there is something simple, but I don't see it. Example: ASC("A") = 65 CHR(65) = "A" ASC("ਔ") = 2580 CHR(2580) = "ਔ" ...

Is there a good browser based sandbox to practice Javascript?

I am looking for recommendations for a browser based javascript sandbox to practice some proof of concept code. ...