javascript

How to iterate headers of sys.net.webrequest (ajax)

How can I iterate over the headers in the sys.net.webrequest object. The documentation says it is a dictionary, but there seems not to be an easy way to iterate over the dictionary. ...

When is the 'javascript:' prefix valid syntax?

I know that you can use a javascript: pseudo protocol for URLs in an <a> tag. However, I've noticed that Firefox and IE will both allow 'javascript:' to precede javascript code within a <script> tag. Is this valid syntax? Does it change the scoping rules? Examples: I've seen this many times: <a onclick="javascript:alert('hello world...

ASP.NET validation not executing in a JavaScript showModalDialog call

I currently open a pop up window from my parent page using using a JavaScript .showModalDialog function. The pop up window contains some ASP.NET validation controls which do not display when the user clicks the ASP.NET button to submit the form. If there is an error on the page, the validation message(s) do not display, the record is n...

This DIV is not shown on Internet Explorer

Hi I need to do some alert-message (like validations, etc), and I'm doing that with DIV. This is how I'm doing the validation: <form action="index.php" method="post" onsubmit="return validateSearchKeyword();"> <input class="text_search" id="text_search" name="text_search" type="text" value="pesquisar" onfocus="if (this.value=='pe...

Is there anyway to trap the closing of a web browser?

Two years ago I had a need to trap the closing of a web browser as a javascript event for a web app. At the time I found there was no way doing this that worked for all browsers. IE had an event that I could used, but it was IE specific. I looked into other work arounds, like a heart beat sort of ping to the server, but I didn't like ...

In javascript, how would you build a method that compares value A with value B

I have an array of objects, something like this: var myArray = [ { 'name' : 'some name', id: 23131, 'has' : ['dogs'] }, { 'name' : 'some name 2', id: 8678, 'has' : ['dogs', 'cats'] }, { 'name' : 'some name 3', id: 2125 , 'has' : ['donkeys', 'goats']}, { 'name' : 'some name 4', id: 90867, 'has' : ['parrots', 'treasure'] }, ...

On Item Added event on an Drop Down List (Option selector)

Given a drop down list, is there any way to subscribe a javascript even which will be fired when a new item is added to the list? I'd like something like the following to work $("select").itemAdded(function(value, text) { alert(text + " has just been added to the list of options"); }); $("select").append($("<option></option").va...

How to move div with the mouse using jquery ?

I need to be able to move a div with my mouse and store the new pos of the div in database to remember the display. How can I do it? ...

jQuery: How to match first child of an element only if it's not preceeded by a text node?

I'm trying to match the h4 of a div (using jQuery) so that I can remove it's top margin. However, I only want to match the h4 if it has no text on top of it. For example, match this: <div> <h4>Header</h4> ... </div> but not this: <div> Blah blah blah. <h4>Header</h4> ... </div> The best code I could come up with in jQue...

How do you convert a color image to black/white using Javascript?

How do you convert a color image to black/white using only Javascript? AND, also make it cross compatible in most browsers because I hear Internet Explorer has a "filter" mechanism but no other browsers support it. ...

Multiple user controls and javascript

I include a JS file in a user control. The host page has multiple instances of the user control. The JS file has a global variable that is used as a flag for a JS function. I need the scope of this variable be restricted to the user control. Unfortunately, when I have multiple instances of the control, the variable value is overwritten...

jQuery .find() doesn't return data in IE but does in Firefox and Chrome

I helped a friend out by doing a little web work for him. Part of what he needed was an easy way to change a couple pieces of text on his site. Rather than having him edit the HTML I decided to provide an XML file with the messages in it and I used jQuery to pull them out of the file and insert them into the page. It works great... In F...

Return value from function with an Ajax call

Can someone tell me how to return the value of status as the function's return value. function checkUser() { var request; var status = false; //create xmlhttprequest object here [called request] var stu_id = document.getElementById("stu_id").value; var dName = document.getElementById("dName").value; var fileNam...

disabling the Ctrl+N and File->New options on browsers

How do you disable the Ctrl+N/File->New options from browser windows, specifically for IE. ...

How can I fade-out a row (TR) in IE6 or 7

I'm using JQuery to fade-out rows (TR) when the user clicks a Delete button on a row (TR). By fade-out, I mean the entire row (TR) background-color is changed to an off red and then it fades to white and disappears. This is a great little animation for showing the user an instant reaction for what the did. The JavaScript looks like th...

How can I reference an encapsulated javascript function from another encapsulated function?

I'm new to object oriented javascript. I have a set up method that I want to a) check if an element is null and if so wait and call itself again and b) observe the click event of a button. ErrorBox.prototype.setUpErrorBox = function(btnClientID) { if (btnClientID == null) { setTimeout("setUpErrorBox()", 1000) return...

Does JQuery have a way to unbind events in random HTML string?

I'm using JQuery to set the HTML inside a div. Something like this: $(div).html(strHtmlBlob); strHtmlBlob is a chunk of HTML returned via Ajax from the server. After, it's assigned, I set up some events for elements in the new HTML blob by doing this: $(div).find("a").click(a_ClickHandler); That all works perfectly fine. The pro...

JQuery toggle VAT switching

Hi , I want to implement a VAT switcher as you can see on http://aria.co.uk top right corner although I want to do it on the client side only. Below is something I came up with, although I need to: switch VAT back and forth (my example goes just one way) save and read the toggled state from a cookie for persistency have it unobtrusiv...

How to pass the html name of button group to a javascript function

Say I have a function similar to this: function getGroupValue(group) { for (var i=0; i < group.length; i++) { if (group[i].checked) { return group[i].value; } } } that i can call with something like getGroupValue(document.forms[0].myGroup) How do I convert this to just pass...

IE 7 stops responding

In our asp.net 2.0 web application, there is a user control with validation. For some reason, when the validation fails, the pages looks fine, however, no controls (asp buttons, scroll bars, or third party like Telerik text editor) respond to mouse inputs. The only work around is to resize the browser window which will make the UI respon...