javascript

Patterns for avoiding jQuery silent fails

Is there any good practice to avoid your jQuery code silently fail? For example: $('.this #is:my(complexSelector)').doSomething(); I know that every time this line get executed, the selector is intended to match at least one element, or certain amount of elements. Is there any standard or good way to validate that? I thought about...

document.onclick settimeout function javascript help

Hi, I have a document.onclick function that I would like to have a delay. I can't seem to get the syntax right. my original code is <script type="text/javascript"> document.onclick=check; function check(e){do something} I tried the below, but that code is incorrect, the function did not execute and nothing happened. <script type...

Fancybox Question

Is there a way to open two pictures in one frame? ...

WYSIWYG editor security question (preventing malicious input)

I'm using jWYSIWYG in a form I'm creating that posts to a database and was wondering how you can prevent a malicious user from trying to inject code in the frame? Doesn't the editor need brackets (which I'd normally strip during the post process) in order to display styles? ...

I can't get ExternalInterface.addCallback to work - trying to call an AS3 function from a js button click.

I'm trying to use ExternalInterface.addCallback to allow js to call an as3 method. My code is as follows: AS: ExternalInterface.addCallback("sendToActionscript", callFromJavaScript); function callFromJavaScript():void{ circle_mc.gotoAndStop("finish"); } JS: <button type="button" onclick="callToActionscript()">Switch to square</...

Facelet components layouts and javascript

Hi all, I have a question regarding the placement of javascript within facelet components. This is more regarding best practice/style than a programming issue, but I feel like all the solutions I have thought of have been hacks at best. Ok here is my scenario: I have a facelet template like so (my faces, and apache Trinidad)... <ui:com...

How to return $(this)

I'm using jQuery and made a plugin for some in house work that basically builds URLs for our internal API. Anyways, I want to return $(this) and im not getting the right thing and im getting a createdocumentfragment error? Plugin code: $.get(base_url,{ agenda_id:defaults.id, action:defaults.action+defaults.type, output:defa...

How do I access a DIV from javascript, if ASP.NET mangles its ID?

I have a web page that contains a "div" element. On the page, there is javascript to reference the div: document.getElementById('divId'). This was working fine until another developer redesigned the page to use an ASP master page. Now, document.getElementById('divId') returns null. It appears that ASP.net prepends some characters to ...

Algorithm for Text Wrapping Within a Shape

I am looking for an algorithm to wrap text within a non-rectangular shape, preferably based on the Knuth and Plass algorithm. The hardest part of this is that the lines may have different heights due to differing font sizes in the text. The image below is an example of what the algorithm should be able to generate. Thanks for any hel...

Are there any JavaScript libraries exclusively for WebKit?

With mobile devices or embedded systems you often support only one browser for performance and memory reasons. With traditional JS libraries you must limit yourself in features and performance to support as many browsers as possible. This is exactly what I would like to avoid. Are their any JavaScript libraries out there focusing only o...

Accessing properties in an ActiveX object through Silverlight/JavaScript.

I've written an ATL/ActiveX object which exposes various properties and methods through its COM interface. I'd like to be able to access those methods and properties from a Silverlight application. The problem I'm running into is that I can access the methods from Silverlight/C#, but I haven't figured out the right syntax for accessing...

Add class to textbox when invalid, using .Net Validators

I'm working on a multipage form in .Net using AJAX (UpdatePanels). I am stuck right now trying to get a class added to the textbox that is invalid to basically highlight it red. I found a sample online using this code: $("span.invalid").bind("DOMAttrModified propertychange", function (e) { // Exit early if IE because it throws...

How to get the Input checkbox id value using javascript?

I have input checkbox something like this.. <input class="inputchbox" id="Pchk" type="checkbox" name="check" value="<%=Model.ID%>" /> using javascript I need to get the all checkbox checked Ids in to the array? how do I need to get? thanks ...

Why is my JavaScript Twitter feed not working in Internet Explorer?

We're rolling out a redesign of helpcurenow.org, and we've implemented a Twitter feed in the footer. (I'm the design & front end guy, my coworker is the scripting & backend guy). All is well with the Twitter feed in all major browsers except internet explorer, version 8 and later. However we have no clue why IE is not pulling the feed...

[JS] How to manipulate a PHP Array in javascript?

I have an Array in PHP which contains data from database. And it prints out also as a table in the same page which has an AJAX delete function. Trying to explain better The array contains debt sums related to many people, it is the application's main function. In the same page, there is a table containing every debt record related to ...

Splitting Nucleotide Sequences in JS with Regexp

I'm trying to split up a nucleotide sequence into amino acid strings using a regular expression. I have to start a new string at each occurrence of the string "ATG", but I don't want to actually stop the first match at the "ATG". Valid input is any ordering of a string of As, Cs, Gs, and Ts. For example, given the input string: ATGAAC...

Passing input value thru XML loop and return value

"X" is reading the form value, but it is still passing and older "var thisMarket" value. The objective is to take a zip code via HTML form: <form id="market" name="market" onSubmit="return validateZIP(this.zip.value);" method="get" action=""> <input type="text" name="zip" id="zip" value="zipcode" onfocus="if(!this._haschanged){this.v...

How to gray out HTML form inputs?

What is the best way to gray out text inputs on an HTML form? I need the inputs to be grayed out when a user checks a check box. Do I have to use JavaScript for this (not very familiar with JavaScript) or can I use PHP (which I am more familiar with)? EDIT: After some reading I have got a little bit of code, but it is giving me probl...

time delay between 2 lines of code in javascript, not settimeout

is there a function that would add a time delay between 2 lines of code. Not the settimeout, because settimeout requires a function/object in its arguments. I am looking for something like this pseudo code write "abc"; delay(500); write "xyz"; TIA Edit: jimr's solution in my other thread worked for my purpose, and so is Robusto's....

Another floating point question

I have read most of the posts on here regarding floating point, and I understand the basic underlying issue that using IEEE 754 (and just by the nature of storing numbers in binary) certain fractions cannot be represented. I am trying to figure out the following: If both Python and JavaScript use the IEEE 754 standard, why is it that exe...