javascript

How to force IE to show page content before finishing all Javascript execution?

On a Ruby on Rails development environment, a page will be shown after 30 seconds on Firefox, but takes 90 seconds on IE 8 (with IE 7 Compatibility Mode). Further investigation shows that it should be Javascript that slowed down the page, because if Javascript is turned off, then the page content will also show in 30 seconds. Because t...

Form submit doesn't work

Hello, I’ve spent the past hour search the web for possible solution, maybe I’m not using the right terms. I hope someone would be able to help me here. I have a form used inside the fancyBox iframe, after adding this ”if statement” below my submit button doesn’t work any more. However if I select more then 5 days I get the error alert ...

If Javascript code block is not at end of HTML file, but is using jQuery's $(document).ready(function() {...}), will it slow down the page display?

It is said that Javascript code should be all placed at the end of HTML file, so that the page content is shown first, for the user to see something (so that the user is satisfied to see something instead of waiting another 12 seconds, for example). But to better encapsulation of the HTML and match Javascript code, such as an "Image Car...

Javascript, string: test string for presence of sub-string that includes an asterisk (*)

I'm doing a pretty basic string matching test as follows: if(msList.indexOf(textChoice) != -1) This works well except that occasionally the sub-string I'm looking for (textChoice) ends with an asterisk. Then I end up getting false matches because the asterisk in the string is interpreted as an operator, not a character in the string. ...

In Ruby on Rails, how to make HTML as partials in one file and Javascript in another file to be included last?

A lot of time, in a partial, the HTML (or ERB or HAML) as well as the Javascript is in one file, so when the main file includes these partials, the HTML will be intermixed with Javascript code. However, it is said that for fast page content display, all Javascropt code should be placed at the end of the HTML file. In this case, is ther...

jQuery - remove function attached to div

I'm running into a problem with jQuery, so I think I've figured out a workaround, but need help. I currently attach a cycle() slideshow to my div like this: function startSlideshow() { $('#slideshow').cycle({ some parameters }); } When I pause and restart this slideshow, it exhibits weird behavior, due to bugs in the cycle plugin...

Javascript widgets that can be POSTed or update via AJAX -- tips?

Does anyone have any tips for creating versatile Javascript widgets that can be used both in a 'new record' form for POSTing, and in an 'edit record' page with instance AJAX updates. For example, a map that can operate in these two modes: create record: markers are added, and included in the form when it is POSTed edit record: as each ...

Jquery/javascript detect and capture page refresh events?

I have an AJAXed page, but I also offer a query string to the user so that he/she may type in the query string to the url to see the same page again. (Think google maps and its "share link" feature). When the AJAX request occurs I update the query string presented to the user, but the actual URL does not change. The problem is, if a us...

Preventing JavaScript Injections in a PHP Web Application

What are the measures needed to prevent or to stop JavaScript injections from happening in a PHP Web application so that sensitive information is not given out (best-practices in PHP, HTML/XHTML and JavaScript)? ...

Desktop like web apps and JS frameworks ?

I am still learning javascript and the more i learn the more i ask myself why do i need to learn a js framework like cappuccino, sproutcore, qooxdoo, smartclient etc...? The learning curve for these frameworks is steep, also wouldn't it be better to just make use of JavaScript libraries? Take note, that my objective is to create desktop...

Libraries/Examples of Hover or Click Menus for web pages/apps, where to start?

I'm changing the layout of a web app that we are developing internally and have identified a few spots where a menu would be much more helpful than our currently layout. The project is currently built on Zend Framework and jQuery. Are they any good examples of context menus, or just menus in general that I should check out for inspiratio...

How to make a javascript/php chatroom more efficient in terms of load time and sql communication

Right now the setup for my javascript chat works so it's like function getNewMessage() { //code would go here to get new messages getNewMessages(); } getNewMessages(); And within the function I would use JQuery to make a get post to retrieve the messages from a php scrip which would 1. Start SQL connection 2. Validate that i...

Is it possible to add ScrollTo to my accordion FAQ page?

I'm using this accordion script for a simple FAQ page. http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm I tried adding http://mix26.com/demo/local_scroll/index.html the ScrollTo so when a question is opened, it scrolls down to it automatically for a better user experience. Can someone please help me? ...

Does the onchange attribute work in non-traditional elements?

Since events bubble up in the DOM, it seems like a change event should be able to reach any container element (e.g. div, table, or ul elements). Therefore, it seems like any such elements should support the onchange attribute. However, it seems like only a few element types support this in the official standard. Despite this, I was able...

Functional JavaScript: how to implement Function.prototype.not

I was working on some code earlier today, when I realized, "Hey! This code would be more concise and semantic if I abstracted the idea of a boolean not out of an anonymous function and into a prototype function..." Consider a predicate generator: function equalTo(n) { return function(x) { return n==x; }; } So you can ...

Styling 'FILE' input type element

How do I properly style a 'file' button with an image, so that it is seen clean and nice in all browsers and no overlapping text from the default control is there? Thank you! ...

What is a regular expression that will remove all "function foo() { ... }" and show other content?

That is, given a Javascript file, this regular expression can show only the "immediate execution" of code, removing all the function definitions in the form of function foo() { ... } Or can regular expression find the "matching { }" because there can many nested { } ...

How to handle large data sets for server-side simulation --> client browser.

Sorry for the somewhat confusing title. Not sure really how to title this. My situation is this- I have an academic simulation tool, that I in the process of developing a web front-end for. While the C++-based simulator is computationally quite efficient (several hundredths to a tenth of a second runtime) for small systems, it can gen...

JavaScript minification of string literals?

I was looking over some of our JavaScript compression and noticed that no strings that aren't object property names are minified into variables. For example, let's say I have these two pieces of code in my script: alert("Wrong answer"); alert("Wrong answer buddy"); The minification we get from YUI and Closure, if I'm not mistaken, is...

Help with JavaScript Function

I am new to JavaScript (but not programming) and am having a difficult time figuring out where I made a mistake in this function, found here: http://mikeryan.webatu.com/function.html The function should take a DDMMYY timestamp and convert it into a human-readable string. For instance, 210710 would be turned into July 21st, 2010. I've lo...