Skip to content
Advertisement

Href=”#” Don’t Scroll

I am pretty new to JS – so just wondering whether you know how to solve this problem. Current I have in my code Which runs some JS to close a box. The problem I have is that when the user clicks on the link – the href=”#” takes the user to the top of page when this happens. How

How to run two jQuery animations simultaneously?

Is it possible to run two animations on two different elements simultaneously? I need the opposite of this question Jquery queueing animations. I need to do something like this… $(‘#first’)….

How do you select a CSS class in Scriptaculous JavaScript?

Here’s a snippet of my code: My Firebug development plugin says: $(“.myclass”) is null I have tried various other names, such as: $(‘div.myclass’) and $(‘myclass’), to no avail. How do I get this effect to work on a class? Thanks! Answer $$ in prototype (and mootools) accepts any sort of css selector like $$(‘div#joe’) or $$(‘a[rel=awesome]’) and returns an array.

How to get a JavaScript object’s class?

I created a JavaScript object, but how I can determine the class of that object? I want something similar to Java’s .getClass() method. Answer There’s no exact counterpart to Java’s getClass() in JavaScript. Mostly that’s due to JavaScript being a prototype-based language, as opposed to Java being a class-based one. Depending on what you need getClass() for, there are several

Disable pasting text into HTML form

Is there a way using JavaScript to disable the ability to paste text into a text field on an HTML form? E.g. I have a simple registration form where the user is required to input their email twice. The second email entry is to verify there are no typos in the first email entry. However if the user copy/pastes their

Close all popup windows with Javascript

Does anyone know how can I close all popup windows (window popup by javascript) in Javascript? Example: Open 3 new windows by clicked on a button, and using window.open() to open all 3 new windows. Clicked on a button and close all 3 popup windows togather. Answer Second result on Google. Closes ALL Windows after storing them in an array.

Smart way to truncate long strings

Does anyone have a more sophisticated solution/library for truncating strings with JavaScript and putting an ellipsis on the end, than the obvious one: Answer Essentially, you check the length of the given string. If it’s longer than a given length n, clip it to length n (substr or slice) and add html entity … (…) to the clipped string. Such

Execute Background Task In Javascript

I have a cpu intensive task that I need to run on the client. Ideally, I’d like to be able to invoke the function and trigger progress events using jquery so I can update the UI. I know javascript does not support threading, but I’ve seen a few promising articles trying to mimic threading using setTimeout. What is the best

Benefit of using ‘window’ prefix in javascript

Are there any benefits to using the ‘window’ prefix when calling javascript variables or methods in the window object? For example, would calling ‘window.alert’ have an advantage over simply calling ‘alert’? I can imagine using the prefix could give a small performance boost when the call is made from inside some function/object, however I rarely see this in people’s code.

Advertisement