javascript

How do I prevent Mozilla XMLSerializer from capitalizing nodes

I'm creating an XML Document in javascript on the client side, and then transforming it back to a string to send to the server. Mozilla has a handy method to accomplish this: XMLSerializer().serializeToString(), which I'm using. However, there seems to be a bug in this method: it returns all node names in uppercase and all attribute name...

How do you restrict the size of a file being uploaded with JavaScript (or Java) without transferring the entire file?

Is there a way to validate on the client side browser whether the size of a file being uploaded from a JSP page is over a set size limit without forcing the user to upload the entire file only to find out it was too large? I would like to stay away from any proprietary controls or techniques like Flash or ActiveX if possible. Thanks! ...

Cross-browser onload event and the Back button

For all major browsers (except IE), the JavaScript onload event doesn't fire when the page loads as a result of a Back button operation - it only fires when the page is first loaded. Can someone point me at some sample cross-browser code (Firefox, Opera, Safari, IE ...) that solves this problem? I'm familiar with Firefox's pageshow eve...

Possible to detect the *type of mobile device* via javascript or HTTP Headers?

I've got a request from a customer to automatically detect the type of mobile device (not the browser, the type. ex: Moto Q, Blackjack II, etc.) and automatically select the device from a drop down with a list of supported devices. So far I've found that the HTTP Headers (submitted by mobile IE) contain information such as Resolution ...

How can I clear the console in firebug from Javascript?

e.g., does this exist: console.clear()? ...

IE7 form not prompted for remember password when submitted through javascript

I have a website where we use Javascript to submit the login form. On Firefox it prompts the user to remember their password, when they login, but on IE7 it doesn't. After doing some research it looks like the user is only prompted in IE7 when the form is submitted via a Submit control. I've created some sample html to prove this is t...

Check/uncheck parents and children

Hi all, Can you do a better code? I need to check/uncheck all childs according to parent and when an child is checked, check parent, when all childs are unchecked uncheck parent. $(".parent").children("input").click(function() { $(this).parent().siblings("input").attr("checked", this.checked); }); $(".parent").siblings("input")...

onbeforeunload support detection

I'd like to check if the current browser supports the onbeforeunload event. The common javascript way to do this does not seem to work: if (window.onbeforeunload) { alert('yes'); } else { alert('no'); } Actually, it only checks whether some handler has been attached to the event. Is there a way to detect if onbeforeunload is s...

How do you find the largest font size that won't break a given text?

I'm trying to use CSS (under @media print) and JavaScript to print a one-page document with a given piece of text made as large as possible while still fitting inside a given width. The length of the text is not known beforehand, so simply using a fixed-width font is not an option. To put it another way, I'm looking for proper resizing...

Can you combine multiple images into a single one using JavaScript?

I am wondering if there is a way to combine multiple images into a single image using only JavaScript. Is this something that Canvas will be able to do. The effect can be done with positing, but can you combine them into a single image for download? Update Oct 1, 2008: Thanks for the advice, I was helping someone work on a js/css onl...

jEditable - problem with input-box styling.

First time i try out this service. Looks promising :D I am trying to style an input-box that is being rendered by the jQuery-plugin jEditable. What I basically want is to only change the color of the table-cell when the text is double-clicked and made editable. Like this: This is where I am at the moment: jEditable CSS Problem ( dou...

What are some good pop-up dialog boxes for Ruby on Rails

I want to use modal pop-up windows in our web app in Ruby on Rails. Note that I don't want to create a new browser window, but a sub-window inside the existing webpage. We've tried things like TinyBox, but there are issues with returning error information from inside the controller. Any good method or tool that works well in ruby? ...

jQuery Grid Recommendations

What are the most recommended jQuery grid plugins out there? I've been messing around with Flexigrid which seems to be fairly decent. Are there any other noteworthy ones out there I should be looking at? ...

How do you convert pixels to printed inches in JavaScript?

I want to resize the font of a SPAN element's style until it the SPAN's text is 7.5 inches wide when printed out on paper, but JavaScript only reports the SPAN's clientWidth property in pixels. <span id="test">123456</span> And then: #test { font-size:1.2in; /* adjust this for yourself until printout measures 7.5in wide */ } And ...

How do I perform an action after an UpdatePanel updates?

When I have a regular textbox in a UpdatePanel (not an ASP.NET control) with some JavaScript events on it, after the UpdatePanel updates my events are gone. Is there a way to re-attach my events after the update? (Preferably without putting my events inline). ...

Cross Browser Flash Detection in Javascript

Does anyone have an example of script that can work reliably well across IE/Firefox to detect if the browser is capable of displaying embedded flash content. I say reliably because I know its not possible 100% of the time. ...

What tasks do you use JavaScript for the most?

What types of JavaScript scripts do find most useful in your work? What tasks do you use JavaScript for the most? Are there scripts that you wished were out there but just haven't been able to find? I'm trying to create a library of MooTools plugins and so I'm always looking for inspiration and advice. I'm trying to concentrate on utilit...

What is the best way for a website to check if a user has installed a client app?

Let's say I've got a website that works better if a client has installed and logged into a desktop application. I'd like to be able to do 2 things: Alter the website if they haven't installed the app (to make it easy for them to find a link to the installer) If they've installed the app on a couple of machines, determine which machine...

Scriptaculous sortable matrix

Hi all! I am trying to create a sortable image matrix, 5x5 using scriptaculous javascript library by I can't make it work. I am trying using a table but I am having trouble linking the <td> into the Sortable object. Do you guys have any hint or documentation I can go through to create this ? Thanks ...

Javascript Commands Only Executed When Unminimized

I want to log to the console when I'm using unminimized JS files. Comments are taken out already when I minimize JS. I'm wondering if there's a way I can write a command that isn't commented out but will still be taken out when I minimize the javascript file. ...