javascript

Firefox "onerror" would not fire even when image is not valid

Hi folks, I have a onerror handler on the image tag to handle switching when the remote image is not found. the problem is that for certain broken remote images, it does not work. http://a3.twimg.com/profile_images/522455109/calvin-and-hobbessm_normal.jpg <img onerror="this.src='/images/pic_not_found.png'" src="http://a3.twimg.com/p...

tumblr avatar img resize (solved) need help with calls to load additional comments

Hello, I'm relatively hopeless with JavaScript writing, and I'm trying to resize the default tumblr avatar image on a notes page. Currently there is no way to include a large avatar in your notes, so I'm trying to use a basic regular expression to replace the dynamically generated URL. A user's avatar is generated into something like t...

Does anyone have a tool which can automatically attempt to refactor javascript to a more prototype/oo style?

It looks to me like it might be possible to, in many cases, automatically perform some of the refactoring required to turn a functional and/or class style javascript source into a more prototype/non-class based oo source. Has anyone made a serious attempt at writing a tool that does this kind of automatic refactoring? ...

Lightweight jQuery (or non-jQuery) slider control?

I need something like the slider control from jQueryUI, but I don't want to use the whole framework for only one control. I tried searching Google but I get results for image sliders rather than the type of control I'm after. Perhaps there is another name for this kind of control? I found only this Which is exactly what I want, but it...

Run PHP code inside JavaScript? Would this be ok to use?

I am not sure if a line of PHP could be run inside of a JavaScript function. For example: <script language=javascript> var int=self.setInterval("message()",1000); function message() { <?PHP mysql_query("SELECT * FROM example"); ?> } </script> I haven't tried to run this, but I don't think you can run PHP like this. Could anyone he...

How to access JavaScript objects in code behind (C#/ASP.NET)

Hi, I am using the web kit browsers local database to temporarily store some data and when I want to access it I create an object function patientSelectHandler(transaction, results) { var row = results.rows.item(0); var patient = new Object(); patient.name = row['name'] patient.dob = row['dob'] ...

javascript code that scrolls to top when a button is clicked

If you click on the navigation links on Hardly Code's website the browser scrolls to another section of the page. Can anyone point me to some good reading materials for recreating this effect? I am using jquery, and want the animation to be as smooth as is it on hardlycode.com ...

Can loop unrolling or duff's help this situation?

I am using this bit of code in order to reformat some large ajax responseText into good binary data. It works, albeit slow. The data that I am working with can be as large as 8-10 megs. I need to get this code to be absolutely efficient. How would loop unrolling or Duff's device be applied to this code while still keeping my binary dat...

what is the validity of the facebook javascript sdk access token that is stored in the cookie

If I use the facebook javascript and xfbml to get a user to login to my app and grant me offline permissions. Can I then at the server read the cookie set by facebook, get the access token store it in a db and use it over time or is this access token valid only during the active session "even though I've requested and obtained us...

Alternatives to database in Ajax

I am new to Ajax programming and I have been told that there are alternatives to using a database in Ajax if optimal speed is required. If there are going to be like a hundred requests per second then using a database does not make much sense. So what are those alternatives? I need only "native" AJAX solutions. No libraries, please. La...

[javascript] how to check 01 02 number

var val= $('#num').val(); // 01 if(isNaN(val) || val > 59 || val== ''){ alert("error"); } In this case, has not alert error var val= $('#num').val(); // 01 val = parseInt(val); ...

How do I allow a webpage to update while a javascript is running?

There has to be an easy way to do this, but I'm new to JS. I have a javascript program that (1) takes user input, (2) updates the webpage based on that input, then (3) performs a lengthy calculation. The trouble is that the webpage doesn't register the update till after the lengthy calculation. Isn't there a way to pause execution s...

how to make sure everything is loaded in ajax using jquery

Hello everyone I got trapped when Im using jquery loading some content into my page. The code is like this: $("#holder").fadeout(); $("#holder").load("test.html", callbackfn); function callbackfn(){ $("#holder").fadein(); } test.html <div style="background-image:url(1.jpg);">test</div> That's the main idea, and actually it wor...

YUILoader comboBase setting for Google CDN

I'd like to use Google's hosted version of YUI (since Yahoo's doesn't support SSL). I'm using YUILoader: var loader = new YAHOO.util.YUILoader({ require: ["autocomplete"], onSuccess: function() { ac_ready = true; setup_manager_autocomp() }, combine: true }); I'm loading yuiloader from Google's CDN: <script src="https://aj...

javascript function to remove diacritics

Hi, I'm searching for javascript function to replace French diacritics and came accross this code: String.prototype.removeDiacritics = function() { var diacritics = [ [/[\300-\306]/g, 'A'], [/[\340-\346]/g, 'a'], [/[\310-\313]/g, 'E'], [/[\350-\353]/g, 'e'], [/[\314-\317]/g, 'I'], [/[\354-\357]/g, 'i'], [/[\...

Are callbacks always asynchronous?

This example is JavaScript, since that's where I'm using callbacks mostly. I want to understand how they work at a low level. In the example below, I'd expect everything to happen in order and "calling back" to occur after "step 3" and before "step 4." This makes sense to me, as everything is done in order on a single thread of execut...

Writing a javascript conditional - active/inactive button

Hi there, I have this script, which works great at the moment to navigate window.uicontrols.createTabBarItem("home", "Tab 1", "icon1.png", { onSelect: function() { jQT.goTo("#home", "slide"); } }); window.uicontrols.createTabBarItem("tab2", "Tab 2", "icon2.png", { onSelect: function() { jQT.goTo("#tab2", "slide"); } })...

How do I fetch another websites info from a URL like Digg's submit button?

I'm creating a website using the cakePHP framework and I and a newbie to php and web programming. I want to do something similar to Digg's submit button, where you type a url and it fetches an image, title and sometimes a short description of the article on the webpage. I'm assuming this would be done using php but I'm open to any meth...

trying to hide/show div with jquery by clicking one link

here's my js: $(document).ready(function() { $('.LoginContainer').hide(); $('.list li a').click(function(){ $('.LoginContainer').toggle(); }); }); This only makes the div with class="loginContainer" appear for a split second and then dissapear. I want for the div to appear when I click the link, and then dissapear w...

compute sum dynamically with javascript

I would like to compute sum of subtotals dynamically but i always get this error: document.getElementById("item_subtotal[" + cnt + "]") is null My javascript code: function calculateTotalAll(numitems) { var cnt = 1; var totalAmt = 0; while(cnt <= numitems) { totalAmt = parseInt(totalAmt) + parseInt(document.g...