javascript

Google Closure minifier online?

Has anyone setup an online copy/paste utility for Google's Closure minifier? I'm working on a project and I want to minify part of the code manually without having to setup the entire project on my own. ...

Getting a color from the CSS class using prototype

Lets say I have a couple of CSS classes: .tickup { color: green; } .tickdn { color: red; } .tick { color: black; } Then I have JavaScript (which is using Prototype) that needs to dynamically change color of another element. That's easy - $('element').style.color = 'red'. But the thing is that the page is skinned, so my only way is to ...

Adding Sizzle js to my project breaks the project

I'm not entirely sure what's happening here. I have my code that exists like: var mycode = { init:function(){ //my code here } } //sizzle pasted here... (function(){ //sizzle code here })(); Where "sizzle code here" is the copy/paste of Sizzle in its entirety. Sizzle is contained in an anonymous function, so I'm not s...

Large http uploads failing with uploadify/php on Dreamhost

Ive been having trouble with a php and JavaScript upload script accepting large file uploads with Dreamhost. I realize that you are supposed to edit php.ini to change post max size and the memory limit, but it isn't behaving as it should. The only way I have ever successfully had a large file upload was switching to Dreamhost PS and mak...

Adding Javascript EventListener only if no other listener is present?

Hello, I'm a relative tyro in the Javascript programming arena, so please go easy on me. :-) I am trying to add an eventListener to various DOM elements on a page. However, some of the elements I'm adding my event to already have an eventListener, and I don't want to supersede that one; I only want to add my event to an element that ...

Updating facebook status with message from a Javascript variable

Hey all, quick question. Is there an easy way to let users update their status on Facebook with a message I have in a JavaScript variable? I know there's a URL you can use to share a link, which looks like: <a href="http://www.facebook.com/sharer.php?u=www.fthisclass.com/jshoregen.html&amp;t=title"&gt;testlink </a> That doesn't fill ...

What's wrong with this Javascript Code?

I believe something on this code chunk is not properly coded making it incompatible on XHTML 1.0 Transitional. The code snippet collapses div and then on click they will expand. Can somebody see what could be wrong? <script type="text/javascript"> function toggle(div){ el = document.getElementById(div); if (el.style.display == 'n...

Check if string contains characters & whitespaces, not only whitespaces

Okay this one might be a bit tricky. What would be the best way to check if a string contains only whitespaces? The string is allowed to contain characters combined with whitespaces, but not only whitespaces. ...

Detecting if onsubmit was cancelled by another event handler?

I would like a way of detecting/triggering a function when the form onsubmit is cancelled by any onsubmit handler. What's the most reliable method for doing this? ...

Checking the referrer

I'm using this to check if someone came from Reddit, however it doesn't work. var ref = document.referrer; if(ref.match("/http://(www.)?reddit.com(/)?(.*)?/gi"){ alert('You came from Reddit'); } else{ alert('No you didn\'t'); } Suggestions on the regular expression are most welcome too ;) ...

javascript selection/range coordinates

I would like to absolute-position a div on either the initial or terminal corner of a text selection, as the user drags their mouse along. Unfortunately, Range only provides the index position, not the x/y coordinates. I think there might be a way to do this with range.insertNode, but only for one side. (This might also help someone posi...

On-The-Fly Image Generation in PHP

I'm developing a script that will allow people to generate a banner for them to use. It's customizable. During the customization process, I'd like to be able to have the banner reload on the spot. So they could see the changes. Once they create the banner and are completely done with it I would give them a link for them to use. This link...

Does 'un-filled' form inputs slow down a website?

I have a page which has a drop list inside a form. The drop list contains 'Categories' of ads. Depending on the value chosen in the drop list, I use javascript to show/hide DIVS on the page, which all contain different form inputs for the user to fill in. All this still inside the form! Now, when the user has filled in all form inputs ...

Hide select option in IE using jQuery

Currently I am using jQuery to hide/show select options using following code. $("#custcol7 option[value=" + sizeValue + "]").hide(); This works fine in Firefox, but doesnt do any good in other browsers. How to I hide options from select in Chrome, Opera and IE? ...

dom:loaded not firing until the last <img> request is initiated. (prototype js)

Hi all, I'm working on a page with 60+ images and the dom:loaded event isn't firing until the last image request is initiated (not fully loaded, which is expected). On a slower connection (using some throttler to simulate this) it is very noticable. The dom:loaded event fires something that will kick in javascript interaction on the pag...

Using javascript on Facebook

Facebook has a special javascript call for setting Fanpage permissions. Unfortunately, I can't get any javascript to work on my page. Not even a simple alert('bla') in an onclick works. Am I missing something? This is the call I want to make: Facebook.showPermissionDialog("publish_stream", ondone, showProfileSelector, [000000]); ...

Calculating time difference with three time values

I'm having trouble calculating a time (hours:minutes) difference between three time values presented as HH:mm strings. I'm calculating time worked in a day from time in, lunch time and time out. e.g. var time_worked = time_out - lunch - time_in or 07:00 = 17:00 - 01:00 - 09:00 I'm familiar with the php dates but the javascript date o...

unresolved symbols / missing ] after element list

I'm removing the button interface from a Flash AS2 drawing tool. All the actions performed by the SWF buttons are now called from the HTML via JS and ExternalInterface. The drawing tool can add text creating a TextField, and draw or add an image creating an empty MovieClip When the JS code calls the method to create the TextField, Fire...

Using the mouse wheel to scroll a browser window horizontally

I have a very wide website, intentionally designed to have no vertical scrolling but a lot of horizontal. Scrolling horizontally is usually a pain to users so was wondering if there was some way of using the middle mouse or other scrolling habits (eg. page up/down, up/down arrows, middle mouse click/drag) to scroll horizontally instead ...

Updating Javascript

I'm trying to create an updating clock in Javascript. Everything is working correctly as I step through the debugger, except that it's not actually updating the span. Any ideas why? <script type="text/javascript"> // The following line of code is in a setInterval() // time is set correctly, according to my debugger document.getElement...