javascript

Javascript auto pick keywords from HTML

Given a body of HTML, is there any function out there someone has written that will automatically extract say the top 10 keywords that appear from a chunk of HTML, excluding any HTML tags (IE just plain text)? It should ignore common words like "and", "is" "but" etc but list the most frequent uncommon words. Example input: Mary had a ...

Updating data from jqueryui dialog - size limit problem

I am using jquery datatables to display data from a mysql database. When you click on a row, a jquery ui dialog box opens with a form for the data, and buttons to update or delete the entry. The code for the update button uses serialize to send the data to a PHP script, like this: buttons:{ "Update": function() { $("#result p")...

Is a request for the .js files still made if a browser has JavaScript disabled?

When a browser has JavaScript disabled, is the request for the .js files still made to the server (ie the files still end up downloaded on the client, but not parsed) ? The reason I'm asking is to see if it's worth implementing lazy-loading JavaScript files as to prevent the browser from requesting them if JavaScript is disabled; ie onl...

Which is better for JavaScript load-time: Compress all in one big file or load all asynchronously?

Hi, A simple question that I'm not sure if it has a short answer! Description I have a files of JavaScript that to be loaded in a website here are some notes about them: They are all comes from the same domain (no cross domain loading needed) They are identical around the website. There are several files, like jQuery, and 5 other plu...

Javascript problem when returning function?

I have a function like this: function ban_rot(){ var bnr = new Array(); bnr[0] = "/Graphics/adv/businesscrown.gif"; bnr[1] = "/Graphics/adv/webbdesigna.jpg"; num = bnr.length - 1; i = Math.round(Math.random(bnr) * num); return '<img src=\"' + i + '\" alt=\"\" border=\"1px\" style=\"border-color:#000;\">'; } I then have a html code: <...

JQuery Validation Problem

I doing a field validation using jquery to check if it is empty. If it is I want to display a message and then refocus on the field so the user can enter some data. Code: $('#fieldId').blur(function() { var fieldValue = $(this).val(); if(fieldValue == null || fieldValue.length == 0) { $(this).addClass('error'); ...

"Div hover" is working but not valid (yet)

I have a problem with this script : click here. Currently it's working perfectly. But if i would run this through the w3 validator it's not 'valid'. I also know why this is, it is because the entire div is within a link. I would like to make this work exactly the same, but also have it score as w3 valid. I have been struggeling for two...

[JS] Verify image size

Alright so here it goes, I have my user system working perfectly, and now in the edit profile, I'm trying to add a change avatar URL option. At the moment it's working great, but for pageloads time and such, I'm looking to restrain the normal users to a maximum of 300px images width, and let's say around 500px height, that are then resi...

JQuery ajax loader and browser caching

I am using JQuery to load some data dynamically via ajax. Whenever the user initiates the ajax request (i.e. clicks a button, or loads a page etc.), I display an ajax loader gif. Once the ajax requests completes (or errors out) I hide the loader image. This works great most of the time. But I noticed (in IE7 for instance) that ajax ca...

620: Too many queries using Google Maps API

I'm using the Google Maps Javascript API V3 to reverse-geocode a lot of locations (~100) on a page. After about 10 or so, I start getting a 620 error: too many queries. What's a good way to delay the requests and ensure that they all get completed given that they're asynchronous? EDIT: Here's what I have so far. It completes all the re...

Sending data to django server from a non-django server

Hi all, I am making a bookmarklet where I need people to login first. My question is how do I send login credentials to the django server from a different domain? I was thinking there were a couple ways, since I can't use send data via request. Generate the sha1 algo on the client-side...but then how do I know what Django is salting ...

What event does JQuery $function() fire on?

We have a JQuery $(function() statement as: <script type="text/javascript"> $(function(){ //Code.. }) </script> Dumb question - when exactly is this function executed? Is it when the entire HTML page has been downloaded by the client? What is benefit of using the wrapping your code within $(function() as opposed to just doing: ...

Dojo - submitting form by pressing Enter

Hello, I have the following code: <div dojoType="dijit.layout.ContentPane" id="filterForm" style="padding: 3px"> <form dojoType="dijit.form.Form"> <input dojoType="dijit.form.TextBox" style="width: 120px" /> <button dojoType="dijit.form.Button" type="submit"> Filter </button> <script type...

jQuery autosave form example?

Does anyone know of a working jQuery autosave example, one with an actual demo. I've been looking for a few days and have tried a few examples but I have yet to get one to work correctly http://forum.jquery.com/topic/auto-save-plug-in http://plugins.jquery.com/project/autosave http://ideamill.synaptrixgroup.com/?p=3 are a few that i'v...

JavaScript: Looping over array

Would it be wrong to conclude that the fastest way to loop over a JavaScript array would be to use the for-in loop? E.g.: for (var index in items) { ... } See http://jsperf.com/loop-test2/2 ...

window.open object change parent element?

I'm not the most javascript savy. I've seen posts for children windows getting parent values but not vice versa. Basically, I want to invoke a window object with window.open. After some user input is entered in the new window, I want to stuff that input into the original window that invoked the window.open. The only ways I can think to...

Finding out if a URL param exists in JS-ASP

I am editing other people's code, written in server-side JS for ASP, and have run into a problem that probably has a very simple solution. I'm outputting some code from a URL param like this: <%=Request.QueryString("param")%> The problem is that if the param doesn't exist, I need to do something else. So I tried: <% var param = R...

Determining creation date of an image in Javascript?

I'm attempting to create a page that displays and refreshes an image from a webcam (camimg.jpg), but displays a static image (notlive.jpg) if the image hasn't been updated recently. I've found the AJAXCam script, which serves the purpose of reloading the "live" image at a set interval (15 secs), yet with no Javascript experience I can't ...

alert() return different from console.log()?

Should I be using alert() for debugging; or is there a time to use alert() vs. console.log()? I see that alert() and console.log() can return different results. I assumed that they were similar functions but just returned in different places. Back story: my boss likes to see alerts() during development but I can't get the object detail...

Override Alert Message from an IFrame?

I've been trying to capture the alert dialog of an iframe unsuccessfully. The iframe is on a different subdomain but the same domain. This doesn't seem to log the output to Firebug from the iframe Alerts function alert(message) { console.info(message); } Do I need to reference the iframe by it's DOM layer somehow? Is wind...