javascript

Track when user hits back button on the browser

Is it possible to detect when the user clicks on the browser's back button? I have an Ajax application and if I can detect when the user clicks on the back button I can display the appropriate data back Any solution using PHP, JavaScript is preferable. Hell a solution in any language is fine, just need something that I can translate t...

Will .NET MVC give me the HTML/CSS/JS separation I need?

I'm working with my ASP.NET development team to try and create "better" (i.e. cleaner) HTML when rendering pages. At the moment, .NET has a nasty tendency to do things like dump JavaScript into the page, making it a mandatory requirement on form controls and not allowing forms to work when JS isn't available. In some instances, we're s...

How can I get a fixed-position menu like slashdot's comment filtration menu

Slashdot has a little widget that allows you to tweak your comment threshold to filter out down-modded comments. It will be in one place if you scroll to the top of the page, and as you scroll down, at some point, where its original home is about to scroll off the page, it will switch to fixed position, and stay on your screen. (To see...

How do you set focus to the HTML5 canvas element?

I'm using the HTML5 <canvas> element in Firefox 2.0.0.16 and in Safari 3.1.2, both on my iMac. (I've tried this in Firefox 3.0 on Windows as well, also to no avail.) The tag looks like this: <td> <canvas id="display" width="500px" height="500px"> </canvas> </td> I have a button to "activate" some function...

ASP.Net AJAX JavaScript Serialization Error

Ran into an “Out of Stack Space” error trying to serialize an ASP.Net AJAX Array object. Here is the scenario with simplified code Default.aspx MainScript.js function getObject(){ return new Array(); } function function1(obj){ var s=Sys.Serialization.JavaScriptSerializer.serialize(obj); alert(s); } function function2(){ v...

jQuery and Java applets

I'm working on a project where we're using a Java applet for part of the UI (a map, specifically), but building the rest of the UI around the applet in HTML/JavaScript, communicating with the applet through LiveConnect/NPAPI. A little bizarre, I know, but let's presume that setup is not under discussion. I started out planning on using j...

How do I put a link to a webpage in a JScript Alert dialog box?

I would like to put a link to a webpage in an alert dialog box so that I can give a more detailed description of how to fix the error that makes the dialog box get created. How can I make the dialog box show something like this: There was an error. Go to this page to fix it. wwww.TheWebPageToFix.com Thanks. ...

Find Missing Javascript Includes in Website

Say I have several JavaScript includes in a page: <script type="text/javascript" src="/js/script0.js"></script> <script type="text/javascript" src="/js/script1.js"></script> <script type="text/javascript" src="/js/script2.js"></script> <script type="text/javascript" src="/js/script3.js"></script> <script type="text/javascript" src="/js/...

Javascript array with a mix of literals and arrays

I can create the following and reference it using area[0].states[0] area[0].cities[0] var area = [ { "State" : "Texas", "Cities" : ['Austin','Dallas','San Antonio'] }, { "State" :"Arkansas", "Cities" : ['Little Rock','Texarkana','Hot Springs'] } ] ; How...

How do I get JavaScript to open a popup window on the current monitor

Scenario: The user has two monitors. Their browser is open on the secondary monitor. They click a link in the browser which calls window.open() with a specific top and left window offset. The popup window always opens on their primary monitor. Is there any way in JavaScript to get the popup window to open on the same monitor as the i...

Can I override onbeforeunload for a particular element?

I have a page which does quite a bit of work and I don't want the user to be able to navigate away from that page (close browser, hit back button, etc.) without getting a warning. I found that the onbeforeunload event (which I think is IE-specific, which works fine for me as the project uses lots of ActiveX) works great. Problem is, I w...

How to convert decimal to hex in JavaScript?

How do you convert decimal values to their hex equivalent in JavaScript? ...

jQuery: Remove all classes that begin with a certain string

I have a div with id="a" that may have any number of classes attached to it, from several groups. Each group has a specific prefix. In the javascript, I don't know which class from the group is on the div. I want to be able to clear all classes with a given prefix and then add a new one. If I want to remove all of the classes that begin ...

How can I close a browser window without receiving the "Do you want to close this window" prompt?

How can I close a browser window without receiving the "Do you want to close this window" prompt"? The prompt occurs when I use the window.close(); command. Derek ...

Something special about Safari for Windows and AJAX?

Some common pitfalls I should keep in mind? ...

Javascript syntax highlighting in vim

Has anyone else found VIM's syntax highlighting of Javascript sub-optimal? I'm finding that sometimes I need to scroll around in order to get the syntax highlighting adjusted, as sometimes it mysteriously drops all highlighting. Are there any work-arounds or ways to fix this? I'm using vim 7.1. ...

How can I check for IsPostBack in JavaScript?

I need to run a JavaScript function onLoad(), but only do it if the page loaded the first time (i.e. is not the result of a postback). Basically, I need to check for IsPostBack in JavaScript. Thank you. ...

Coding Dojo with IE and SSL

My application is using Dojo 1.1.1 on an SSL-only website. It is currently taking advantage of dijit.ProgressBar and a dijit.form.DateTextBox. Everything works fabulous in Firefox 2&3, but as soon as I try the same scripts in IE7 the results are an annoying Security Information dialog: This page contains both secure and nonsecure item...

How do you get JavaScript/jQuery Intellisense Working in VS 2008?

I thought JQuery Intellisense was supposed to be improved with SP1. I even downloaded an annotated version of jquery 1.2.6, but intellisense will not work in a separate jscript file. I have the jquery library referenced first on my web page in the tag. Am I doing anything wrong? ...

How do I stop an effect in jQuery

I have a page that uses $(id).show("highlight", {}, 2000); to highlight an element when I start a ajax request, that might fail so that I want to use something like $(id).show("highlight", {color: "#FF0000"}, 2000); in the error handler. The problem is that if the first highlight haven't finished, the second is placed in a queue a...