javascript

Detecting font in JavaScript

Suppose I have the following CSS rule in my HTML. body { font-family:Calibri,Trebuchet MS,Helvetica,sans-serif; } How can I detect which one of the defined fonts was used in the user's browser? Edit for people wondering why I want to do this: The font I am detecting contains glyphs not available in other fonts and when the user does n...

What JavaScript library would you choose for a new project and why?

There seem to be a lot of choices now for DOM manipulation, Ajax and effects. Has anyone any experience of the different options and their pros and cons? ...

ASP .Net Custom Client-Side Validation

I have a custom validation function in JavaScript in a user control on a .Net 2.0 web site which checks to see that the fee paid is not in excess of the fee amount due. I've placed the validator code in the ascx file, and I have also tried using Page.ClientScript.RegisterClientScriptBlock() and in both cases the validation fires, but c...

Triple Quotes? How do I delimit a databound Javascript string parameter in ASP.NET?

How do I delimit a Javascript databound string parameter in an anchor OnClick event? I have an anchor tag in an ASP.NET Repeater control. The OnClick event of the anchor contains a call to a Javascript function. The Javascript funciton takes a string for it's input parameter. The string parameter is populated with a databound val...

How can I make the browser see CSS and Javascript changes?

CSS and Javascript files don't change very often, so I want them to be cached by the web browser. But I also want the web browser to see changes made to these files without requiring the user to clear their browser cache. Also want a solution that works well with version control system such as Subversion....

CSS Background Color in Javascript

How can I set the CSS background color of a HTML element via JavaScript?...

Capturing TAB key in text box

Here on Stack Overflow, I would like to be able to use the tab key within the WMD editor text box to tab over 4 spaces. The way it is now, the tab key jumps my cursor down to the Tags. Vote for this feature at UserVoice: http://stackoverflow.uservoice.com/pages/general/suggestions/15889 Is there some JavaScript that will capture the TA...

MAC addresses in JavaScript

I know that we can get the MAC address of a user via IE (ActiveX objects). Is there a way to do the same thing in all browsers? (Especially since FF is gaining browser share everyday!)...

Javascript troubleshooting tools in IE

I use Firebug and the Mozilla JS console like crazy, but every now and then run into an IE-only Javascript bug, which everyone knows are really hard to locate even though you know theyre there (ex: error on line 724, when your source html only has 200 lines!) I would love to have a lightweight JS tool (a la firebug) for IE, something I c...

Call ASP.NET Function From Javascript?

I'm writing a web page in ASP.NET. I have some Javascript, and I have a submit button with an onClick event. Is it possible to call a method I created in ASP with Javascript's onClick event? ...

How can I turn a string of HTML into a DOM object in a Firefox extension?

I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object? It appears that the general solution is to create a hidden iframe and throw the contents of the string into that. There has been ...

Best Debugging Tools for JavaScript/xulrunner Development

In the past few months I began my first serious JavaScript development, as I began developing XUL applications. I use Notepad++ as my editor, but I was pretty appalled to find (as far as I can tell) that Venkman/Javascript Debugger is the tool for debugging. It seems like a poor replacement to Visual Studio for .Net languages. Am I mi...

Http Auth in a Firefox 3 bookmarklet

Im trying to create a bookmarklet for posting del.icio.us bookmarks to a seperate account. I tested it from the command line like: wget -O - --no-check-certificate \ "https://seconduser:[email protected]/v1/posts/add?url=http://seet.dk&description=test" and this works great I then wanted to create a bookmarklet in my ...

Javascript keyboard events primer? (or rather: help me with my custom dropdown)

I need help finishing my custom built ajax [div] based dynamic dropdown. Basically, I have an [input] box which; onkeyup, runs an Ajax search which returns a bunch of results in divs and are drawn back in using innerHTML. These divs all have highlights onmouseover so, a typical successfull search yields the following structure (pardon ...

Wrapping lists into columns

I'm using ClodFusion(sic) to populate a template that includes HTML lists (<ul>'s). Most of these aren't that long, but a few have ridiculously long lengths and could really stand to be in 2-3 columns. Is there an HTML, ColdFusion or perhaps JavaScript (I have jQuery available) way to do this easily? It's not worth some over-complicat...

How to set up a CSS switcher in ASP.NET

I'm working on a website which will switch to a new style on a set date. The site's built in semantic HTML and CSS, so the change should just require a CSS reference change. I'm working with a designer who will need to be able to see how it's looking, as well as a client who will need to be able to review content updates in the current l...

How Do I Post and then redirect to an external URL from ASP.Net?

ASP.Net server side controls postback to their own page. This makes cases where you want to redirect a user to an external page, but need to Post to that page for some reason (for authentication, for instance) a pain. An HttpWebRequest works great if you don't want to redirect, and Javascript is fine in some cases, but can get tricky i...

Length of Javascript Associative Array

If I have a javascript associative array say: var myArray = new Object(); myArray["firstname"] = "Gareth"; myArray["lastname"] = "Simpson"; myArray["age"] = 21; Is there a built in or accepted best practice way to get the length of this array? EDIT: JavaScript does not have associative arrays -- it only has objects. ...

How to specify javascript to run when ModalPopupExtender is shown

The ASP.NET AJAX ModalPopupExtender has OnCancelScript and OnOkScript properties, but it doesn't seem to have an OnShowScript property. I'd like to specify a javascript function to run each time the popup is shown. In past situations, I set the TargetControlID to a dummy control and provide my own control that first does some JS code a...

Getting the text from a drop-down box

This gets the value of whatever is selected in my dropdown menu. document.getElementById('newSkill').value I cannot however find out what property to go after for the text that's currently displayed by the drop down menu. I tried "text" then looked at W3Schools but that didn't have the answer, does anybody here know? For those not su...