I'm having a bit of a go slow in the brain department today and thought maybe somone had done this before.
Given the numbers below, what simple means could I use in Javascript to work out the decimal point as a number, eg:
1 = Decimal point: 0
10 = Decimal point: 1
1678 = Decimal point: 3
-0.56 = Decimal point: -1
-0.0045 = Decimal p...
I'm trying to add a listener to DOM change events. I was hoping something as simple as 'dom:loaded' was baked into Prototype. I'm not sure of the 'Prototype-way' to handle this.
EDIT: I cannot control every case in which the DOM may be altered, so I can't get away with firing a custom event on every DOM change.
...
I hear nothing but great things about the newest version of jQuery 1.3. Has anyone experienced any problems upgrading from 1.2.6? I would love to use it but I want to know if there are any gotchas first.
EDIT: 1.3.1 is out.
...
I'm using Prototype's PeriodicalUpdater to update a div with the results of an ajax call. As I understand it, the div is updated by setting its innerHTML.
The div is wrapped in a <pre> tag. In Firefox, the <pre> formatting works as expected, but in IE, the text all ends up on one line.
Here's some sample code found here which illustr...
An HTML text input has an attribute called "maxlength", implemented by browsers, which if set blocks user input after a certain number of characters.
An HTML textarea element, on the other hand, does not have this attribute. My goal is to emulate the behavior of maxlength on an HTML textarea. Requirements:
At a minimum, show (CSS chan...
Based on this question
I don't want to litter my ready stuff waiting for a "click event" AND a "change event" AND a "mouseover event" I want to have all that stuff in a single function or event.
Is is possible to chain the events together. I want to capture not only a keyup, but also a click or a change in case the user isn't on the ...
I have a neat little javascript data grid and I want people to be able to paste data into it. I know there are security issues attached to accessing the clipboard, but I am wondering if there is a way to do it. It is by far the most intuitive approach for the end user.
Is there some cunning hack I could do with, say, a text input?
...
I have a long snippet of HTML I want some javascript variable to equal and for maintainability I want to store it with actual newlines instead of adding \n (or as it is HTML just omitting newline characters). In Python I would do something like:
largeString = """Hello
This is long!"""
And that would work perfectly. However, I haven't ...
I have a few places where I use the line below to clear out a status for example. I have a few of these that hang out for 10 seconds or more and if the user gets clicking around the action can occur at incorrect time intervals. Is it possible to cancel or kill this w/ some jQuery or JavaScript so I don't have this process hanging aroun...
Hi,
First question on here so please be nice :)
I know very little about regular expressions but I am using one in a current project which strips special characters from a string. It looks like this...
newWord = newWord.replace(/[^0-9A-Za-z ]/g, "");
It works well, but I need to modify it slightly so that it doesn't remove the £ (GB...
I was wondering if there is a cleaner (more succinct) way to do what each() is doing in following JavaScript code.
$(".moreinfodialog")
.before('<a href="#">Click for more info.</a>')
.each(function() {
var temp = this;
$(this).prev("a").click(function() {
$(temp).dialog("open");
return f...
How do I open 'cross-domain security', so the JavaScript on the page can freely communicate with the SWF, even when this is hosted on another domain?
I know for certain that this function communication is blocked by default, but by playing around with a file called "crossdomain.xml" and the actionscript 3 function: system.Security.allow...
Are there any in-place editor in JS that supports Rich Text like TinyMCE / FCKEditor?
e.g. of in-place editing (non-rich text): http://www.appelsiini.net/projects/jeditable/default.html
...
ok, people here is my amazing antigravity library. I'm trying to define it as an object literal, which, uh, i read all the cool kids are doing in order to to encapsulate their libraries. Basic tests indicate it's working properly, but I cannot seem to see document.body from inside my object.
what should happen is when I click on the p...
My HTML has
cell = document.createElement("td");
cell.appendChild(document.createTextNode(contents));
cell.setAttribute('width', '100');
// The following syntax not working
cell.appendChild(document.createElement('br')).appendChild(document.createTextNode("Another text"));
And after the contents of the cell, I have a line break fol...
How does one go about attaching a bunch of code to an onkeydown event, but keep entering text into a textarea fast and crisp? Anything more than a couple of IF statements seems to slow it down quite considerably.
EDIT: I should add (can't believe I forgot!) that this doesn't affect desktop browsers. It's mainly an issue with iPhone Safa...
Has anyone been able to do this?
...
Dear All
I have a PHP file going to write a two-dimensional array in javascript:
<?php
print "<script language='javascript'>";
print " extra[0][0]=new Array(1,'Bob',12);";
print " extra[0][1]=new Array(2,'Alice',18);";
..
// need to assign the extra[1][0],extra[1][1] so on.
print "</script>"; ...
Is there any way to get the source line number in Javascript, like __LINE__ for C or PHP?
...
In JavaScript the % operator seems to behave in a very weird manner. I tried the following:
>>> (0 - 11) % 12
-11
Why does it return -11 instead of 1 (as in Python)?
I am sure I am doing or expecting something wrong, but the docs don't tell me what.
...