javascript

Is it possible to destroy a session variable set by ASP.NET (VB.NET) with Javascript?

As the title states, I have a session variable that is set during a login script with asp.net and vb.net code-behind. Can I call a javascript function when a link is clicked that will destroy that session variable? If it is possible, can I use jQuery to make that process easier? ...

Replacing body.onload in a user control

I am refactoring a page that uses <body onload="myJS();"> to a user control. I understand I can do it using server side script registration on load. If I want to do it on the client side (ascx), how would I do this? ...

How to determine if Native JavaScript Object has a Property/Method?

I thought this would be as easy as: if(typeof(Array.push) == 'undefined'){ //not defined, prototype a version of the push method // Firefox never gets here, but IE/Safari/Chrome/etc. do, even though // the Array object has a push method! } And it does work fine in Firefox, but not in IE, Chrome, Safari, Opera, they return all pr...

Is it possible to append to innerHTML without destroying descendants' onclick functions?

In the following example code, I attach an onclick handler to the span containing the text "foo". The handler is an anonymous function that pops up an alert(). However, if I append to the parent node's innerHTML, this onclick handler gets destroyed -- clicking "foo" fails to pop up the alert box. Is this fixable? <html> <head> <scri...

Link in popup window does not close the window?

I have this bit of html code, but when I click the link, it does not close: <html> <head> <title></title> </head> <body> <h2>Members Only</h2> <p>You must be a member.</p> <p>Please Sign In or Create an Account.</p> <a href="javascript: self.close ()">Close this Window</a> </body> </html> ...

JavaScript Cheat Sheet

I am looking for a reference card for JavaScript - for example a summary of syntax and methods parameters. Google gives me lots of choices. What is a good one? ...

detect window width and compensate for scrollbars - Javascript

How do I detect the width of a user's window with Javascript and account for their scrollbar? (I need the width of the screen INSIDE of the scrollbar). Here's what I have...it seems to work in multiple browsers...except that it doesn't account for the scrollbars.. function browserWidth() { var myWidth = 0; if( typeof( window.inn...

Update iframe body color after load

I have a page ,page1.html that loads page2.html via an iframe . I need to change the body color of the iframe page (page2.html) to override the CSS style that's loaded on page2.html. (both pages are on same domain). How can that be updated via Javascript ? ...

How do I convert a float to an int in Javascript?

I'd like to convert a float to an int in Javascript. Actually, I'd like to know how to do BOTH of the standard convertions: by truncating and by rounding. And efficiently, not via converting to a string and parsing. ...

Popup window keeps opening after I close it and refresh the page?

I have an aspx.cs page with the following code: hypPopup.Attributes.Add("onclick", "window.open('Popup.aspx', '', 'height=650, width=800, location=no, toolbar=no, st...

Check what control initiated AJAX Request

asp.net 2.0 / jQuery / AJAX <script type="text/javascript"> //updated to show proper method signature var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(hideMessage); function hideMessage(sender, args) { var ctl = args.get_postBackElement(); //check if ctl is the disired control //hide user notifi...

How do I limit my date range on an Ajax Calendar?

I am using the ajax calendar tool. I like its function, but I would like to restrict the user to an option of selecting a time frame starting with Today, and ending with 6 months prior. How do I do this? ...

JavaScript Profiler like JetBrains dotTrace?

I'm a big fan of dotTrace for my web application and I wanted to find a solid javascript profiler that functions about the same way. I've looked around and can't seem to find a JavaScript profiler like that. Anyone know of a Javascript profiler like dotTrace? ...

How can encode a query string so that it is the value of another query string in javascript?

I have a javascript function which passes as a query string value another query string. In other words, I want the query string to be: http://www.somesite.com/?somequery=%3fkey%3dvalue1%2520%26%2520key2%3value3 However, if I redirect like this: var url = 'http://www.somesite.com/?somequery='; url += escape(?key=value1&key2=value2); ...

Element.prototype in IE7?

I'm trying to extend all dom elements so i can get and remove their children. The function is below (works in FF and Chrome). Is there an equivalent in IE7 to extend the base dom object? if (!Element.get) { Element.prototype.get = function(id) { for (var i = 0; i < this.childNodes.length; i++) { if (this.childNodes[i].id == id) { ...

How do you clone an Array of Objects in Javascript...

...where each object also have references to other objects within the same array? When I first came up with this problem I just though of something like var clonedNodesArray = nodesArray.clone() would exists and searched for info on how cloning objects in javascript. I did find a question on StackOverflow (answered by the very same ...

Understanding JavaScript - Resource

Using the tiny Diggit/Blog feature of StackOverflow described here: I would like to post the following Google tech talk video I have just saw and that I found quite interesting. I have always had problems understanding javascript "nature". Here, the JavaScript good parts are described by Douglas Crockford I hope you find this link ...

How to use an anchor link and scroll at the same time?

Hi Guys, Here for some help again :) I've got this site: sharemyplaylists.com that uses this scrolling plugin to smoothly bring the user to an anchor when clicked, here is the code: // Smooth anchor link script $(document).ready(function() { $('a[href*=#]').click(function() { if (location.pathname.replace(/^\//,'') == thi...

How do I create an abstract base class in JavaScript?

Is it possible to simulate abstract base class in JavaScript? What is the most elegant way to do it? Say, I want to do something like: - var cat = new Animal('cat'); var dog = new Animal('dog'); cat.say(); dog.say(); It should output: 'bark', 'meow' ...

JavaScript shells - what is the difference

https://developer.mozilla.org/en/JavaScript_shells lists quite a few shells. What is there to choose between them. ...