javascript

restrict user input using javascript

Hi there, Can someone show me some example for restricting user input (on input tag) in Javascript? Something that when we set the input (type="text") to only accept numeric, so it will ignore any other input except for numeric... I think it's handy for number input (such as zip, credit card, money, value, score, date etc...), and if ...

"google is undefined"

I'm using Gears which works well in FF3 and Safari; IE6/7 both report a "google is undefined" error on page load, appearing in gears_init.js. A quick web search showed that Javascripts by Google are actually causing problems in IE7. Does anybody have an idea for a workaround? ...

How to select the nth item in xpath 1.0?

I have some XML and an XPath query. I'm using Yahoo! widgets, so I'm using XPath 1.0. Here's the gist of my XML... <root> <cat num="SOURCE"> <movie> <swf>speak.swf</swf> <width>250</width> <height>150</height> <colour>cccccc</colour> </movie> <movie> ...

browser cache bypassed in firefox?

Consider the following html page, which can load in many large png files: <html> <head> <script type="text/javascript"> function hide( ) { document.getElementById("here").innerHTML = "hidden"; } function show( ) { var loadMe = ""; for (var i=1; i<250; i++) { loadMe += "<img src='http://domain.com/" + i + "_a.png'><br>...

Debug message "Resource interpreted as other but transferred with MIME type application/javascript"

OK, I understand what the messages means, but I'm really not sure what's causing it. I'm using Safari and the Web Inspector on Mac OS X, by the way. I've got the following in my document head: <script src="http://local.url/a/js/jquery.js" type="text/javascript"></script> <script src="http://local.url/a/js/jquery.inplace.js" type="text/...

JS path in User control

The folder structure we have is something like this: ParentFolder HostPage1.aspx UserControlsFolder UserControl.ascx AnotherFolder HostPage2.aspx UserControl.ascx is used in both HostPage1.aspx AND HostPage2.aspx I am including an external JS file in the ASCX and the path needs to be relative to the Page. Since I...

How to get image with its name and any extension?

I am building an asp.net website. I want to show image on the page, but while I know the image name, I don't know the extension. So, I want to open the images directory and get the image by its name whatever its extension. ...

Age from Date of Birth using JQuery

I need to calculate if someone is over 18 from their date of birth using JQuery. var curr = new Date(); curr.setFullYear(curr.getFullYear() - 18); var dob = Date.parse($(this).text()); if((curr-dob)<0) { $(this).text("Under 18"); } else { $(this).text(" Over 18"); } There must be some easier functions to use to compare dates...

Firing an event from an ASP.NET calendar control's cell.

I am building an Events Calendar using the ASP.NET/C# framework. I am able to display the summary of events in the respective days cells by data binding manually in the 'OnDayRender' event handler. The clients need the ability to click on the events inside the cells to see the details inside a pop up box. The calendar control provided by...

Javascript blocking content download on your website during page

Is this the best way to include javascript on your website? http://www.webdigi.co.uk/blog/2009/avoid-javascript-blocking-content-download-on-your-website-during-page-load/ ...

Add Subversion revision to included Javascript and CSS files

I'm looking adding Subversion's revision number to the name of each .js file we include, so whenever the .js file is updated, the browsers will automatically fetch the new version. I believe Stackoverflow does this, but I wonder how. Is this part of the release procedure? Any hints on how to achieve this using Subversion tools? ...

Why does the script debugger in Microsoft Visual Studio not work for me

I am using Visual Studio 2008, when I start up an Asp.net project that starts IE6, I do not see any jscript file in the “Script Document” folder in the Solution. However if I start up IE by hand and point it at my website, then attach the Visual Studio 2008 debugger to IE, it does show the jscript files in the “Script Document”. Howe...

(Re)Enabling JavaScript debugger in IE7 with Visual Studio 2008

Visual Studio 2008 comes with nice javascript debugging features. But I have played a little with NetBeans debugger wich has installed an ugly Script Debugger from Microsoft to my IE... Normally IE should ask what do I want to use for debugging, but now I can't start debugging with Visual Studio, the Script Debugger is started automatic...

Jquery mouse-over fade-in/out (best practices)

I've got working Jquery code to fade in/out descriptive text in a div below the question. The problem? The solution is not very elegant. Here's what I've got: $("#home").mouseover(function() { $("#homeText").fadeIn("slow"); }); $("#homeText").mouseout(function() { $("#homeText").fadeOut(); }); I know there is better way to do ...

How can javascript stream some contents to the user?

Hi All, I need a Javascript sample which reads contents from a url and creates a file in the client with same contents when some button is clicked. I also understand that Javascript cannot be allowed to access the local file system (Unless you use ActiveX objects). I do not want to rely on ActiveX objects (since my client is not IE alway...

Url Hash with Html Base Tag

window.location.hash When using a link for a javascript action, I usually do something like this: <a href="#">Link Text</a> That way, when someone clicks the link before the page loads nothing terrible happens. Html Base Tag On my current project I use this same construct, but with a base tag: <html> <head> <base href="http://...

How to show popup message like in stackoverflow

I would like to add a popup message like the one that appears on stackoverflow when I am not logged in and I try to use voting buttons. What is the best method for achieving that? Is it done using a jquery library? ...

Please check my Javascript Snippet. It's a greasemonkey script for FB Mobwars

Hey guys, I'm practising my Javascript programming by developing greasemonkey scripts, theoretically it would improve my javascript coding cause it's raw javascript. So now, im coding a script for Mobwars facebook. It's a game where you kill people, steal stuffs, create mobs, etc etc. To understand this better, here's the screenie of t...

How can I shift-select multiple checkboxes like GMail?

In GMail, the user can click on one checkbox in the email list, hold down the Shift key, and select a second checkbox. The JavaScript will then select/unselect the checkboxes that are between the two checboxes. I am curious as to how this is done? Is this JQuery or some basic (or complex) JavaScript? ...

<h2> background-color is not changing with Jquery?

I have an h2 element with an id of title and I have the following script: <script type="text/javascript"> $(document).ready(function(){ $("#title").css("background-color","red"); )}; </script> The background-color is not changing though and I can't figure out why? <html> <head> <title>Table Sorter</title> <script type="text/j...