javascript

How to check browser for touchstart support using JS/jQuery?

In an attempt to follow best practices, we're trying to use the proper JavaScript/jQuery events according to what device you are using. For example, we're building a mobile site that has an tag that will have an onclick or touch event. In the case of an iPhone, we'd like to use the "touchstart" event. We'd like to test if their device s...

Javascript error in rails app (locally run)

Hi, I am trying to move a development environment from production to my local machine (Ubuntu), and when I get the code up and running on my box, the site works in rails but I get this JS error: Permission denied for http://ad.doubleclick.net to call method Location.toString on http://localhost:3000. Line 0 Do you have any idea how ...

A question about John Resig's Simple Javascript Inheritance.

I'm using this simple code: http://ejohn.org/blog/simple-javascript-inheritance/ Using this "library", I made this simple class: var Person = Class.extend({ init: function(openningSentence) { this.say(openningSentence); }, say: function(words) { alert(words); } }); The problem with this class, is that I can't call a f...

Can YUIs DataTable have resizeable but not moveable columns?

I have implemented column resizing with YUIs DataTable as demonstrated in this example: http://developer.yahoo.com/yui/examples/datatable/dt_complex_clean.html Is there anyway to enable column resizing without column moving? ...

Replacing GTileLayer in Google Maps v3, with ImageMapType, Tile bounding box?

I need to update this code: radar_layer.getTileUrl=function(tile,zoom) { var llp = new GPoint(tile.x*256,(tile.y+1)*256); var urp = new GPoint((tile.x+1)*256,tile.y*256); var ll = G_NORMAL_MAP.getProjection().fromPixelToLatLng(llp,zoom); var ur = G_NORMAL_MAP.getProjection().fromPixelToLatLng(urp,zoom); var dt = new...

Detecting regular expression in content during parse

I am writing a simple parser for C. I was just running it with some other language files (for fun - to see the extent of C-likeness and laziness - don't wanna really write separate parsers for each language if I can avoid it). However the parser seems to break down for JavaScript if the code being parsed contains regular expressions.....

Zoom in on a point (using scale and translate)

I want to be able to zoom in on the point under the mouse in canvas with the mouse whell, like when zooming on maps.google. I'd like straight code as I've been working on this for 5h+ 15h Something to start with: After 2 weeks break I did it in 3 min, here is the working code: <canvas id="canvas" width="800" height="600"></canvas> <sc...

jquery thickbox height problem

My thickbox renders correctly in my dev environment, but in prod, the default height kicks in even though I'm supplying width and height params. TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramate...

jQuery Accordion /Tabs - Call different function upon load of content

I have the following markup: <body> <div id="tabs" style="float: left"> <ul> <li><a href="ajax/question_0.html" title="Question 1"><span>Question 1</span></a></li> <li><a href="ajax/question_1.html" title="Question 2"><span>Question 2</span></a></li> <li><a href="ajax/question_2.html" titl...

Javascript: change based on whether IE7 or not

I would like to change a line of my javascript code based on whether the browser is IE7 or not. Here is the code for any other browser: function showHint(myId) { document.getElementById(myId).style.display = "inline-block"; } For IE7, I want display = "inline". I've made an attempt at conditional compilation (this showed me how ...

Post Method XMLHttpRequest Forces Login Dialog(IE issue)

We are running windows IIS 6 and use it's native ability to protect files with Windows Authentication as our login method. It works fine, except that when I try to post method XMLHttpRequest from IE i get the login dialog again, which causes the request to fail. The weird thing is that Mozilla and Safari work well. Is there something I...

Canvas Check before submission

I have a page where a user can draw on the canvas and save the image to a file on the server. The canvas has a default black background. Is there a way to check if the user has drawn anything on the canvas before submitting the data URL representation of the image of a canvas with the toDataURL() function? So if the user doesn't draw an...

Using `this` in Crockford's pseudoclassical inheritance pattern

I've just read The Good Parts, and I'm slightly confused about something. Crockford's example of pseudoclassical inheritance goes like this: var Mammal = function (name) { this.name = name; }; Mammal.prototype.get_name = function () { return this.name; }; Part of the problem with this is that the constructor has "its guts han...

Check if there are any AJAX request alive

I do a lot of AJAX Requests at the same time. I need to know when EVERY requests are over. How do I check that? Thank you! ...

Attached event triggering if event is same as current event

I have a button which start/stops a timer. When I click it, I remove the current event handler, and attach the opposite one. Ie, click "Stop", and the "Start" function is attached for the next click. However in IE (7), not sure about 8. The newly attached event is also triggering after the original function is finished: Lifeline in IE7...

Strange Javascript Problem Involving split("/");

Okay, so using the following function: function date_add(date, days) { var dim = {1:31, 2:28, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31}; console.log(date.split("/")); var date_arr = date.split("/"); console.log(date_arr); ... } I get the following output at the console screen for date_add("12/08/1990", 1...

Is there a JQuery alternative to JQTouch with better Android Support?

Basically looking for a JQuery plugin with better Android browser support than JQTouch. Or even an alternative Javascript framework with better mobile support. ...

Parsing a Vimeo ID using Javascript?

Hi, Could anyone point me in the right direction to parse an ID from a Vimeo URL in Javascript? The URL will be entered by a user so I will need to check that they have entered it in the correct format. I need the ID so that I can use their simple API to retrieve video data. Any help appreciated. ...

How to reinforce pseudo css rules

Is there anyway to reinforce pseudo css rules? ie: I have a listing of divs (playlist) which I color with the following rules: #playlist .playlist_item { background: #d6d6d6; } #playlist .playlist_item:nth-child(odd) { background: #b3b3b3; } Now, when a song is playing, I use setInterval and JQuery's .animate function to pulse...

Assign Id's dynamically to DOM elements with javascript.

Hello everybody, I just have a quick question about how to generate id's on-the-fly for HTML elements. So far I've tried a few things, I started with a "for" loop, I already know how many elements I have to generate Id's for, in this case I have an "ul" with 6 "li". My "for" loop is as follows: var items = $("ul li").length; for(var i =...