whats the best way to tell if a value in javascript is a single digit. Ive been doing something like
var valAsString = '' + val;
if (valAsString.match(/\d/) {}
clarification: I mean one of 0,1,2,3,4,5,6,7,8,9
Also, should what I have work? Im surprised how many different ways people are coming up with for this.
...
I have a variable which holds a relative link for an image. This image link file name can have various lengths. For example...
/v/vspfiles/assets/images/d-amazingamethyst.jpg
/v/vspfiles/assets/images/cdacarbon.jpg
I would like to extract from this variable only the filename with out the .jpg extention and without the preceeding pat...
I'm building a web app with jQuery & Rails. The web app loads pages with AJAX ... no page refresh.
When a user clicks on a link to load a new page via AJAX, i want to update the address bar. I also want to maintain the browser's back button support.
ideas?
...
I'm looking to buy an introductory book and am on a tight budget. There are some good prices for second hand books on Amazon, but I don't want to make a mistake like buying a C# v2 book when v4 is out.
Wikipedia sheds no light, even in the History section of the JS page. For the statement "buy a book published after xxxx and you will be...
Hi, does anyone know of a good regular expression to remove events from html.
For example the string:
"<h1 onmouseover="top.location='http://www.google.com">Large Text</h1>
Becomes
"<h1>Large Text</h1>
So HTML tags are preserved but events like onmouseover, onmouseout, onclick, etc. are removed.
Thanks in Advance!
...
I have an art gallery full of thumbnails. I wanted to add a customized horizontal scrollbar so that users could scroll through a single row of thumbnails. There are different amounts of thumbnails in each gallery. I tried using CSS property "width:-moz-max-content;" however this only works in Firefox and not IE6,7,8, Chrome or Safari.
H...
I'm making a falling sand game in Java. I want users to be able to write their own engine for it using a simpler language. Falling sand games can be very CPU intensive so I want to have the engine running as fast as possible while not having to manually compile.
I need to know how to compile rhino javascript files to .class files by at ...
I'm injecting a script via JSONP and using it to call a method in my web application like so:
(function jsonp(src){
var b = document.body;
var t = document.title;
var u = encodeURI(document.location.href);
var o = document.getElementById('srv-call');
o && b.removeChild(o);
var s = document.createElement('script...
I'm trying to write a bit of code that shrinks the size of the contents of the current page to eliminate vertical and horizontal scrollbars. This script only has to work on Mobile Safari, so I'm not very worried about browser compatibility. Here's what I have so far:
// maxHeight, maxWidth are the height and width of the browser wi...
I trying to learn how to create prototypes in Javascript, but the Array prototype confuses me. I have an Array of Numbers that are stored in the Array as Strings, and I want to convert the entire Array so they are actual numbers. How do I do this an exactly what would I type to activate this prototype?
...
Hello all,
I am developing an embedded web server. Now, I have an access validation page (e.g. http://192.168.1.1/) at the very start that accepts username and password and validates it and later redirects the users to the actual device control web page (http://192.168.1.1/devicecontrol.html). I do not want the actual url to appear on t...
I am working on a site that loads an iframe (from another domain) as a user types into a textbox.
Sometimes, the iframe loads a site that will steal the focus. This is particularly annoying, as the user will have been typing in my textbox, and now will be typing into the iframe's textbox.
It seems there's no way to disable an iframe f...
I read lots of questions about this, but every solution uses the same workaround, submiting the form inside the jquery dialog, something like this:
$("#dialog").dialog({
buttons : {
"Confirm" : function() {
window.location.href = targetUrl;
},
"Cancel" : function() {
$(this).dialog("close");
}
}
Isn't ...
I have the following code, where i'm unable to get a reference to the parent object inside OnKeyUp function. I understand that in the OnKeyUp method, "this" refers to the textbox. But how do i access the parent object so that var textboxID gets me the correct value ?
function $MyObject() {
this.Control = {
i...
Anyone know how to set the width of the InfoWindow in Google Maps? The infowindow is the cartoon like bubble that pops up when you click on a point in Google Maps. I can control the height via CSS but cannot figure out how to change the width (I want thinner than the default infowindow).
I found a reference to maxWidth in the API but I ...
Hi All
I have a div section in which i have an image whose onlick event should execute a function called in it, but it is not executable in FF or chrome with my code, infact the image is not clickable at all . Could some one help me in get the thing done? below is the code i am working with
<div class="addtocart-popup-bg">
<div ...
Hello friends
I am developing a web-site for mobile and i-pod in HTML. I would like a horizontal scroll bar for multiple images in one row, which has a hyper link.
What is easiest method for this?
Thanks in advance for your help.
...
I have a external js file handling deleteing some element. According to the result, I would determine whether I need to refresh the page or not.
var deleted = 0; // first assume not deleted
$(function() {
$("#action a.action-delete").click(function() {
var id = $(this).parent().parent().attr("id");
$.get("modify-s...
Hi,
I'm trying to use the jQuery "Cycle" plugin (http://jquery.malsup.com/cycle/) to rotate testimonials located within <span>s ... however the plugin is causing my content to not be centered. Yesterday morning someone here pointed out the <span> elements are being absolutely positioned by the plugin: $slides.css({position: 'absolute', ...
I am drawing a text in canvas. Its working fine in all other browsers but in ipad safari, its drawing text outside the canvas area and the text is flipped too.
context.font = "14px Arial";
context.fillStyle = "#000000";
context.textAlign = "center";
context.fillText('text', 20, 20,300);
context.stroke();
context.closePath();
...