javascript

why my JS can't load document from another server?

I have two web-sites and two files: provider.com/provide.js viewer.com/index.html viewer.com/index.html renders information to the user, and gets this information from provider.com. The file viewer.com/index.html looks like this (jQuery is used): <script type="text/javascript" src="http://provider.com/provide.js"&gt;&lt;/script&gt; <...

HTML Drag And Drop On Mobile Devices

When you add drag and drop to a web page using JavaScript, such as jQuery UI draggable and droppable, how do you get this to work when viewed via a browser on a mobile device - where the touch-screen actions for dragging are intercepted by the phone for scrolling around the page etc? All solutions welcome... my initial thoughts are: H...

Determine if cursor position is on start of a defined row in textarea

How to determine if cursor position is on start of a defined row in textarea with JavaScript? ...

Getting the contents of an element WITHOUT its children

I have a mild preference in solving this in pure JS, but if the jQuery version is simpler, then jQuery is fine too. Effectively the situation is like this <span id="thisone"> The info I want <span id="notthisone"> I don't want any of this nonsense </span> </span> I effectively want to get The info I want but not The info I want I...

Calculating window dragging and skewing in JavaScript

Hi, I am using JavaScript and trying to make a skew effect on a div. First, take a look at this video: http://www.youtube.com/watch?v=ny5Uy81smpE (0:40-0:60 should be enough). The video shows some nice transformations (skew) when you move the window. What I want to do is the same thing: to skew a div when I move it. Currently I just h...

Submitting form via AJAX and getting response

In my rails app, I need to submit a form via ajax so that the form submit happens behind the scenes and doesn't require a full page reload. I did form_remote_tag, but I can't figure out how to get a response from it make sure it was successful. Is there a way to, or do people just trust it's always successful (eek!)? Or is there a bett...

Converting PHP code into JS

I have this PHP code - <?php for($i=1; $i<=1000; $i++) { $array=array(); $array[$i]=54*$i; $arr=array($array[$i].","); foreach ($arr as $value) { echo $value; } } ?> I tried with: var i; for(i=1;i<=1000;i++) { var array = new Array(); array[i] = 54*i; var arr = new Array(); arr.push(array[i]+","); } alert(ar...

Javascript RegEx Help

I admit, after all these years I suck at regex. I am hoping someone and quickly help me with this. var str = "11 FT 0 IN | 10' ( +$2,667.00 )"; var match = str.match(/**no clue what to do**/g); // results needed match[0] = "11 FT 0 IN"; match[1] = "10'"; match[2] = "( +$2,667.00 )"; ...

In jQuery, IE object doesn't support this property or method, can someone help?

I have been pulling out my hair on this topic. I have been searching google and could not find much to help me. I have this here: http://www.fissiondesigns.com/simon Works in FF and chrome, but can't get it to work on IE, keep getting an error 'object doesnt support this property or method'. I looked it up on google and couldn't find...

Restricting access to some elements in Javascript

Hi everyone, For a project that will let developers add their own Javascript applications, I need to limit scope of Javascript to a certain div. For example, each developer will have access to their own div. <div id="md5_of_a_salt_and_app_id"> <script> /* This area should not be able to modify window element * or ...

JavaScript - Use variable in string match

Hello, i found several similar questions, but it did not help me... so i have this problem: var xxx = "victoria"; var yyy = "i"; alert(xxx.match(yyy/g).length); I dont know how to pass variable in match command. Please help. Thank you. ...

Is there an equivalent of canvas's toDataURL method for SVG?

I am trying to load an svg image into canvas for pixel manipulation I need a method like toDataURL or getImageData for svg on Chrome/Safari I can try doing it through and image and canvas var img = new Image() img.onload = function(){ ctx.drawImage(img,0,0) //this correctly draws the svg image to the canvas! however... var dataURL ...

Why does "dtoa.c" contain so much code?

I'll be the first to admit that my overall knowledge of low level programming is a bit sparse. I understand many of the core concepts but I do not use them on a regular basis. That being said I was absolutely astounded at how much code was needed for dtoa.c. For the past couple months I have been working on an ECMAScript implementation...

Capture the next main block element using JS.

The line in question is the var el2. I'm looking to hilite both the h element the script scrolls to * and * the next main block element (h, p, div, pre etc) below it. The best I've done so far is this: /* ScrollToThenFlash */(function(){var d=document;d.body.appendChild(d.createElement('script')).text="(function(){var d=document;functio...

Trigger javascript function after X number of seconds - with conditions

I have a jquery based slider on the page. This slider calls a function to update a variable each time a value changes and does a few other things. This means that the function is called too often when the slider handle is being dragged. And this is causing performance issues. Current Psudo: Slider.onSlide: trigger function ValueChange(...

Form value addition with js

Hi. I'm trying to write a order form that shows the value of the selected items automatically. The backend is already complete, and on the front end each field, all radio / checkbox, look like this: <input type="radio" name="shirt-size" value="shirt_size_m[18]" /> '18' being the price, everything else being irrelevant to the front en...

JqGrid not loading data from JSON

I have a JQGrid plugin in my website, the table is loading OK, but with no-rows to edit, select or whatever. It is requesting the server because when i watch the log I see the request and it's parameters (sidx, _search, rows, sord, nd, etc). This is the jqgrid code: $(document).ready(function() { var lastsel; jQuery("#rowed3")....

Javascript - Search/React for each result

So if you have the following string: "$(document).ready(function() {" There are three open parentheses "(" I know there is the good 'ol string.replace(/(/g, "replacement_string"); way of doing things, but lets just say that doesn't exist for this question. Now lets say I have a function that does replaces "(" with "?". Is there a way ...

Detecting jQuery Object

I'm writing a plugin for jQuery and I want to make it so the user can pass data to the plugin in any form. I have the JSON or array problem worked out, but I'm having trouble trying to determine if the data is a jQuery object. data = $('#list li'); console.debug( $.isPlainObject(data) ); // false console.debug( $.isArray(data) ); ...

HTML5 canvas: find out if click co-ordinates are inside a given rectangle

Hi All, May be some one has had similar experiences on this dilemma and can help me out here... Basically, I have a canvas element on which I draw several rectangles in a loop using context.fillRect (x, y, width, height) Now, I want some of the rectangles to be hotspots and respond to click events. I can find out the exact (x,y) of...