javascript

How can I submit a form to two different pages (not at same time)?

I need to submit a page to two pages depending on which button is triggering the submit. Both pages needs to be able to pick up the $_POST data being sent. This is what I have so far, but it's not working. <form name="user" action="" method="POST"> <textarea name="tname" id="tname"></textarea> <input type='button' value='Submit' ...

jQuery load() throws "permission denied" error in IE

Hi, I'm loading a page through AJAX with jQuery's load() function. It doesn't work in IE8, giving the "permission denied" error. Using the IE debugger, it seems that when jQuery tries to open up the xhr, ie blocks it. The problem is, my page has a javascript src that points to bing maps js api (which of course is in a completely diffe...

Rails nested attributes javascript add another

I had a model with some nested attributes and needed to add new items via Javascript. This is what I came up with: $('.add_task').click(function() { var last_item = $('#tasks li:last'); last_item.after('<li>'+last_item.html().replace(/\d+(?=\_)|\d+(?=\])/g, function(match) {return parseInt(match)+1;})+'</li>'); }); It does the job...

javascript - Detect if Google Analytics is loaded yet?

I'm working on a project here that will store some info in Google Analytics custom variables. The script I'm building out needs to detect if GA has loaded yet before I can push data to it. The project is being designed to work across any kind of site that uses GA. The problem is reliably detecting if GA has finished loading or not and is...

How to add current url with parameters infront of .attr("href") ?

I have external links <a href="http://notmysite.com/"&gt;Link&lt;/a&gt; and I'd need to add: http://myurl.com?url= before the external link's href. Making it <a href="http://myurl.com/current/page?url=http://notmysite.com/"&gt; My current js code: $.expr[':'].external = function(obj){ return !obj.href.match(/^mailto\:/) ...

Get computed font size for DOM element in JS

Is it possible to detect the computed font-size of a DOM element, taking into consideration generic settings made elsewhere (In the body tag for example), inherited values, and so on? A framework-independent approach would be nice, as I'm working on a script that should work standalone, but that is not a requirement of course. Backgro...

Javascript: Changing color of every "r" in html document.

EDIT [how can I] change the color of every R and r in my HTML document with javascript? ...

how to get controller result in javascript

Hey All, context: onSuccess javascript method after an ajax post How do I obtain my id in javascript that is sent from my controller's ActionResult? On the controller I've tried 2 flavors Content Result and JSON Result and both of those show up as [object] in my alert(). Thanks, rodchar ...

jQuery.ajax call fails inside Chrome extension

I'm porting one of my Firefox extensions to Chrome, and I'm running into a little problem with an AJAX query. The following code works fine in the FF extension, but fails with a status of "0" in Chrome. function IsImage(url) { var isImage = false; var reImageContentType = /image\/(jpeg|pjpeg|gif|png|bmp)/i; var reLooksLikeIm...

how to return variable from the function called by onreadystatechange=function()

I'm using the ajax technique in combination with php and I want to know how to get the return variable from the function that is called by onreadstatechange. A java function is called onsubmit to then call a php script to verify some things in my database and return true or false depending on the results. Here is where I run into probl...

How do I load a page in javascript from its source string?

if I have a javascript variable: var page = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"&gt;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Example&lt;/body&gt;&lt;/html&gt;" and I want to load that page, what do I do? ...

js, img, css and ajaxcall folders?

when i download some new plugins eg. jquery plugins i put them in js folder. and the same for css and img. so all my different applications share them. but where do i put my js/img and css for specific application/website? every website? and where should i put my ajaxcall-files.php? EDIT: some guides that could give me a clean and nea...

Scroll with jQuery

Hi.. I need to do this in jquery with a little animation (the folowing sentece works): window.parent.scroll(coord[0], coord[1]); Does the folowing code to do what I want? because it doesn't, =D $(window.parent).animate({ scroll: coord }, 2000); Any Ideas? Thanks ...

Custom JavaScript as DOM node attribute to perform when it's ready

Can I add a custom JavaScript as some DOM node attribute to perform when it's ready like JavaScript added as "onClick" attribute performed when you click on it? Suppose i need to process a div element with some funcMyTransform function. I think it'll be more elegant to write smth like this <div onReady=funcMyTransform(this)>...</div> ...

Checking Display Value of HTML element and saving to a Cookie in jQuery

I'm trying to use jQuery to toggle the appearance of a shoutbox and remember that state from page to page. My problem is getting the cookie that remembers the state set. Here's the code I've come up with so far, but it doesn't seem to be executing the if statement correctly. Any ideas why? function show_shoutbox() { $('#SB').toggle("f...

Best way for simple game-loop in Javascript?

Is there a simple way to make a game loop in JavaScript? something like... onTimerTick() { // update game state } ...

Optimize loop JavaScript

ai up, look at this silly code. I want to pass either a string or an array and return the data. This code does work, but it sucks. What would you recommend as the best way to remove the duplication and optimizing it as much as possible? thanks :) var getData = function (dataFile) { var ajaxResponse = [], loop, i; if(da...

Facebox - Jquery 1.2.1 close function broken in 1.3.2

I am using "facebox" which uses jQuery 1.2.1 on my website here http://www.pointclickshoot.com/beta2 The rest of my site is using jQuery-1.3.2.js. I need to update the following functions to work with jQuery 1.3.2: /* Bindings */ $(document).bind('close.facebox', function() { $(document).unbind('keydown.facebox') $('#faceb...

Trouble with appending a form in jQuery

Here's my code: $('.reply').click(function() { $leftwrap = $(this).parent(); $comment = $(leftwrap).parent(); $id = $comment.attr('id'); if($(this).siblings('.reply-form').length == 0) { //check whether or not the form as been initiated yet $(this).parent().append('<?php $replytimestamp = strtotime("now"); ?> <form class="reply...

jQuery.data() works in Mac OS WebKit, but not on iPhone OS?

I'm playing around with jQTouch for an iPhone OS app that I've been toying with off and on for a while. I wanted to try my hand building it as a web app so I started playing with jQTouch. For reference, here is the page+source (all my code is currently in index.html so you can just "View Source" to see it all): http://rpj.me/doughapp.co...