javascript

How can I create a javascript badge or widget?

I want to create a javascript badge that displays a list of links. We host the javascript on our domain. Other sites can put an empty div tag on their page and at the bottom a reference to our javascript that would render the content in the div tag. How do you implement something like this? ...

How to change onClick handler dynamically?

I'm sure there are a million posts about this out there, but surprisingly I'm having trouble finding something. I have a simple script where I want to set the onClick handler for an <A> link on initialization of the page. When I run this I immediately get a 'foo' alert box where I expected to only get an alert when I click on the link...

Implementing an editable DropDownList in ASP.NET

What's the most elegant way of implementing a DropDownList in ASP.NET that is editable without using 3rd party components. As a last resort I will probably try using a TextBox with an AutoCompleteExtender with an image to 'drop down' the list; or a TextBox overlapping a HTML Select with some JavaScript to fill values from the Select to ...

How can you programmatically tell an HTML SELECT to drop down (for example, due to mouseover)

Can you do it programmatically? ...

Find all radio groups which haven't been selected

I have a basic quiz/survey type application I'm working on, and I'd like to give the user a prompt before they submit if they haven't answered all the questions. All the questions are multiple choice using radio buttons: <div class="question"> Q1: What is the second letter of the alphabet? <div class="choices"> <input ty...

Scalable google maps overlay

Is it possible to add an image overlay to a google map that scales as the user zooms? My current code works like this: var map = new GMap2(document.getElementById("gMap")); var customIcon = new GIcon(); customIcon.iconSize = new GSize(100, 100); customIcon.image = "/images/image.png"; map.addOverlay(new GMarker(new GLatLng(50, 50), {...

Make a scrollable element stay "at the bottom" while adding content.

I am building a utility page for a web app that I am working on. I have an element that I want to use as a "console" of sorts. I get entries for the console via Ajax calls (using prototype's Ajax.PeriodicalUpdater). The problem I'm having is that when I insert new lines to the bottom of the "console", the scrollbar stays in the initi...

create a balloon popup in taskbar using javascript..

I need to create a function that will produce a balloon popup in the taskbar using javascript. Is it possible? Whats the shortest and easiest way to do this? or else what will be the available method.. Thanks. ...

Passing Eval from ASPX to Javascript function as Parameter

<a id="lblShowTimings" runat="server" title='<%# Eval("SHOW_Name") %>' onclick='PopulateTicketDiv(<%#Eval("SHOW_ID") %>)'> <-- this is the problem %#Eval("SHOW_Time") %> </a> Can Eval be passed as an argument to a javascript function? If so whats the syntax? ...

Can I fetch the value of a non-standard CSS property via Javascript?

I am trying to read a custom (non-standard) CSS property, set in a stylesheet (not the inline style attribute) and get its value. Take this CSS for example: #someElement { foo: 'bar'; } I have managed to get its value with the currentStyle property in IE7: var element = document.getElementById('someElement'); var val = element.curr...

ASP.NET: Warning on changed data closing windows

I'd like to warn users when they try to close a browser window if they didn't save the changes they made in the web form. I'm using ASP.NET 3.5 (with ASP.NET Ajax). Is there a common solution which I could easily implement? EDIT: maybe my question wasn't clear: I am specifically looking for a way which integrates gracefully in the ASP...

Popup detection before user logs in

Is there a good way to determine if a person has a popup blocker enabled? I need to maintain a web application that unfortunately has tons of popups throughout it and I need to check if the user has popup blockers enabled. The only way I've found to do this is to open a window from javascript, check to see if it's open to determine if a...

How to get function to fire when buttonless form is submitted

I have a page with many forms on it. could be 1..200. None of these forms have buttons and they are built programatically. I am using jquery to submit all the forms that are checked. function FakeName() { $("input:checked").parent("form").submit(); } My forms look like: <form name="FakeForm<%=i%>" action="javas...

JavaScript switch statement

I have problem in some JavaScript that I am writing where the Switch statement does not seem to be working as expected. switch (msg.ResultType) { case 0: $('#txtConsole').val("Some Val 0"); break; case 1: $('#txtConsole').val("Some Val 1"); break; case 2: $('#txtConsole').text("Some Val 2"); break; } The ...

ASP.NET Ajax: close window after Ajax call?

I'm using ASP.NET Ajax. How can I tell the browser to close the current window after the server call finishes (server-side code)? I managed to do this using the ASP.NET Ajax's ScriptManager method "RegisterDataItem" in the server method (inside a button click handler): sm.RegisterDataItem(ActionLabel, "action:closewindow") and a hidd...

How does StackOverflow know when there are new answers to a question?

If this question has already been asked I appologies, please point me in the right direction. I was wondering if anyone has any insight into how StackOverflow pops up the "n new answers have been posted, load new answers" thing at the top of a question when you are adding a post. This seems like a very useful function for my forum web-s...

JQuery-bound event handlers

Hi, I want to attach a 'click' event handler to the first child of an element with ID 'foo' using JQuery. I understand that the syntax for doing this is: $('#foo:first-child').bind('click', function(event) { // I want to access the first child here }) Within the handler body I want to access the element which caused the event to b...

count immediate child div elements using jQuery

Hi, I have the following HTML node structure: <div id="foo"> <div id="bar"></div> <div id="baz"> <div id="biz"> </div> <span><span> </div> How do I count the number of immediate children of "foo", that are of type "div". In the example above, the result should be two ("bar" and "baz"). Cheers, Don ...

JS Regex For Human Names

I'm looking for a good JavaScript RegEx to convert names to proper cases. For example: John SMITH = John Smith Mary O'SMITH = Mary O'Smith E.t MCHYPHEN-SMITH = E.T McHyphen-Smith John Middlename SMITH = John Middlename SMITH Well you get the idea. Anyone come up with a comprehensive solution? ...

Weird IE & Javascript issue

So I'm creating some HTML using javascript based on where the user clicks on the page. On page load the script replaces an empty div with a ul and some data. The user clicks on that data to receive more and so on. Now when the user navigates off the page and then hits the back button to go back to the page, IE displays a blank page with ...