javascript

JavaScript bookmarklet to delete all cookies within a given domain

Hello Everyone, I am testing a web app that writes cookies to subdomain.thisdomain.com and several subfolders within that. I'm looking for JavaScript that I can put into a bookmarklet that will delete all cookies under that subdomain, regardless of the folder in which they exist. Any ideas? ...

Select all child elements except the first

Say I have the following: <ul> <li>First item</li> <li>Second item</li> <li>Third item</li> </ul> How would I select all the child elements after the first one using jQuery? So I can achieve something like: <ul> <li>First item</li> <li class="something">Second item</li> <li class="something">Third item</li> </ul> ...

Why am I getting this Javascript runtime error?

I've got the following JavaScript on my web page... 64 var description = new Array(); 65 description[0] = "..." 66 description[1] = "..." ... 78 function init() { 79 document.getElementById('somedivid').innerHTML = description[0]; 80 } 81 82 window.onload = init(); In Microsoft Internet Explorer it causes the ...

Why doesn't this JavaScript display a confirm box?

I am trying to fix some bugs in a product I inherited, and I have this snippet of javascript that is supposed to hilight a couple of boxes and pop up a confirm box. What currently happens is I see the boxes change color and there is a 5 or so second delay, then it's as if the missing confirm just accepts itself. Does anyone smarter tha...

Simple JavaScript question: what is this thing?

var something = { wtf: null, omg: null }; My JavaScript knowledge is still horribly patchy since I last programmed with it, but I think I've relearned most of it now. Except for this. I don't recall ever seeing this before. What is it? And where can I learn more about it? ...

Javascript Post on Form Submit open a new window

http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit shows you how to submit a form that you create via JavaScript via post. Below is my modified code. var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttribute("action", "test.jsp"); var hidden...

Is there any good or reliable way to figure out where a JavaScript error is using only an Internet Explorer error message?

I'm writing an app which for various reasons involves Internet Explorer (IE7, for the record), ActiveX controls, and a heroic amount of JavaScript, which is spread across multiple .js includes. One of our remote testers is experiencing an error message and IE's error message says something to the effect of: Line: 719 Char: 5 Error: Un...

Conflict between Google util.js and ASP.NET AJAX?

I'm trying to use Google's jstemplate as a client-side templating engine on an ASP.NET page, and it seems to be conflicting with ASP.NET AJAX. The problem is not jstemplate.js but util.js, which it needs as a support file. I've isolated the problem as follows:: <%@ Page Language="VB" %> <body> <form id="form1" runat="server"> ...

Clearing all cookies with javascript

How do you delete all the cookies for the current domain using javascript? ...

Crossbrowser equivalent of explicitOriginalTarget event parameter

Hi, Does anyone know of crossbrowser equivalent of explicitOriginalTarget event parameter? This parameter is Mozilla specific and it gives me the element that caused the blur. Let's say i have a text input and a link on my page. Text input has the focus. If I click on the link, text input's blur event gives me the link element in Firefo...

What is the best way to detect and store the timezone the client of a web app is in?

I have a multi-timezone web application that stores all of the datetime values in UTC in the database, when actions happen on the server, I can easily convert the time into UTC. However, when a client enters a time or time span, what is the best way to detect and store it? I am currently doing the following: Get the value of Date.get...

jQuery: how to change title of document during .ready() ?

I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is correct way (if any) to set the title of the document? <script type="text/javascript"> $(document).ready(function() { // ??? }); </script> ...

jQuery DIV click, with anchors

To make click-able divs, I do: <div class="clickable" url="http://google.com"&gt; blah blah </div> and then $("div.clickable").click( function() { window.location = $(this).attr("url"); }); I don't know if this is the best way, but it works perfectly with me, except for one issue: If the div contains a click-able element, ...

Where are the DataValueField values for a CheckBoxList stored?

I have this CheckBoxList on a page: <asp:checkboxlist runat="server" id="Locations" datasourceid="LocationsDatasource" datatextfield="CountryName" datavaluefield="CountryCode" /> I'd like to loop through the checkbox elements on the client using Javascript and grab the value of each checked checkbox, but the values don't appear to ...

Is there any way instead of a JS hack where I can post from an iframe to another page outside the iframe?

Is there any way instead of a JS hack where I can post from an iframe to another page outside the iframe? the iframe is posting data to a 3rd party and then just responding back with a URL which is the redirection URl thus we cannot set the form target. We are PCI compliant and thus we cannot use window.parent.location = url; ...

Using javascript and jquery, to populate related select boxes with array structure

Using answers to this question, I have been able to populate a select box based on the selection of another select box. ( I posted my answer here) Pulling the data from an array structure built server-side, stored in a .js file and referenced in the html page. Now I would like to add a third select box. If I had 3 sets of data (model, m...

Close Browser Window after Form Post

Here's my situation. I have a button on my ASP.NET webform. This button creates a new browser window pointing to a page which has a lot of hidden fields (which are dynamically generated). This form submits itself to SQL Reporting Services on the bodies onload event. This works fine and the report is displayed in this new window. Howeve...

Unobtrusive Javascript rich text editor?

We've used the no-longer-supported RichTextBox control as part of our (ASP.NET-based) CMS for a long time, and we'd like to replace it with something lighter-weight and with better cross-browser support. We were originally looking at various ASP.NET components, but I'm wondering if we'd be better off just using an open-source, all-Javasc...

Best javascript syntactic sugar

Here are some gems: Literals: var obj = {}; // Object literal, equivalent to var obj = new Object(); var arr = []; // Array literal, equivalent to var arr = new Array(); var regex = /something/; // Regular expression literal, equivalent to var regex = new RegExp('something'); Defaults: arg = arg || 'default'; // if arg evaluates to ...

Referencing a javascript object literal array

How would you reference the models (Accord, CRV, Prius, etc) in this structure? Is this a bad structure to be able to extract the makes...then use a make to get the models...then use the model to get the options? var cars = [ { "makes" : "Honda", "models" : [ {'Accord' : ["2dr","4dr"]} , ...