javascript

JavaScript: How is "function onload() {}" different from "onload = function() {}" ?

In the answers to this question, we read that function f() {} defines the name locally, while [var] f = function() {} defines it globally. That makes perfect sense to me, but there's some strange behavior that's different between the two declarations. I made an HTML page with the script onload = function() { alert("hello"); } and...

HTML & Javascript performance

I have a website, that is slow-ish. The server responds in around 2 - 300 ms at each request, but it takes 1.5 - 2 seconds for the page to be ready in the browser. By experimenting with disabling javascript and CSS, I have determined that it is the browser's processing, that takes the majority of time. Using Firebug, I see that the D...

Receiving an (unwanted) mousemove event when clicking on an image

I have a html page, on this page there are some images, when the user clicks on one of these images, a different image replaces it. <img style="cursor:hand" src="../_Img/click_me.png" onclick="ChangePic();"> The ChangePic() function: function ChangePic() { var el = event.srcElement; el.src = '../_Img/Clicked.png';} I also have a l...

Problem while executing ajax

I am trying to do a simple application using Ajax and servlet. But when i was trying to execute the application, it is not working. Please go through the code and let me know what would be the problem? function createRequest() { alert("hai createRequest()"); try { req=new XMLHttpRequest(); } catch(trymicrosoft) { tr...

argument passing to a javascript function from an asp.net c# button clock event

i have to pass a string value which is stored in a variable to a javascript function which i'm calling in a button click event of my asp.net c# web application. i have tried some ways but not getting exactly. below is the code which i'm using protected void Button1_Click(object sender, EventArgs e) { myButton.Attributes...

Timing in JavaScript

I am speed testing some JavaScript programs by creating a Date object, and using it to get the time in milliseconds before and after the real work of the function. I made the body a simple adding for loop, and then the end is subtracting the old ms from the new ms and printing that. However, everything finishes in 0 milliseconds... which...

When are JavaScripts executed?

I'm currently asking myself, when javascripts in the header of a page are executed? After all contents are loaded? During loading images? Before loading the site? Reason is, I want to implement a barrier to prevent users accessing a site without javascript (it's for internal company use, don't blame me for the requirement) - my idea wa...

JQGrid: Pager in inline add form

Hi guyz, I'm trying to add next/prev buttons in the default add in form of a jqgrid. Do you have any idea or example to help me? I could add my own buttons, but I'd like to call the same function as framework to navigate... Thanks in advance. Cyril ...

Browser Specific Jquery

I have had to write some JQuery specifically for IE6, fixes some bugs with compatability between IE6 and IE8. However I only want to apply the IE6 JQUERY to IE6 and not have it load with IE8. Can anyone suggest a way of detecting IE6 and running the IE6 Specific JQUERY? ...

Do we have getElementsByClassName in javascript?

Just like in jQuery we can use $(".classname"), is there a similar thing in javascript as well? Or if we don't have such method then how can i implement that. According to http://www.dustindiaz.com/getelementsbyclass/ i will have to iterate through all tags and then collect all elements which are having the same class as specified. I...

Simple JavaScript Animation for 1 Second to Highlight Text?

Hi guys, I searched by google but I found that much I can't overview it all, so I need your experience: I need to highlight a text for 1 second. For example a simple "blink"-effect with a color or something like that. I tried JQuery-Animation allready but it seems very bugged with newer versions of Firefox / Internet Explorer. So d...

Need to Send Email from HTML pages

I m creating a Website as Static HTML pages. In that only in one contacts page alone i need to get the users name and emailId . This information should be send to a particular mail Id with the information of username and emailId. I m using only HTML and Javascript , can anyone say me how to make it possible. ...

get label value in javascript through iframe

i have an aspx page containing following code <body> <script language="javascript" type="text/javascript"> function Hidee() { alert(window.frames["frame1"].document.getElementById("Label1").text); } </script> <form id="form1" runat="server"> <div> <iframe id="frame1" name="frame1" cla...

What's the most JSON you can reasonably expect to decode on the client side

This morning I tried to use ExtJS' JSON decoding facilities against 0.75MB of data, and it crashed FF3. I'm wondering what is the most JSON one can reasonably expect to decode on the client side? This could be using ExtJS, jQuery, other Javascript frameworks or any built-in decoding that Javascript itself may offer. ...

How to solve - DIV element flashes/disappears immediately after it is rendered.

Here's what is happening After the page loads, javascript reads an XML from the underlying code The XML contains a bunch of field-ids, and corresponding content to display in popups when the mouse hovers over a field id listed My code generates a bunch of popups as div-elements with the styles .render{ background-color: #fffc80;...

ASP .NET MVC; return HTML along with JavaScript

I have a partial view which renders a table. On page load, I am using JQuery to perform Zebra Stripping on it. Whenever ajax refreshes the table, DOM elements are updated, but since JQuery code to do the Zebra Stripping is not executed; table looks ugly. I have tried adding Javascript in my partial view if( Request.IsAjaxRequ...

Clueless. jQuery Image Swap problem in Firefox, works on IExplorer 8

Hi all I'm having a problem with a series of social buttons, and their rollover event. I have 6 images, with class 'social32' which I'd like to change from their 'off' status to their coloured one. All files are named like 'facebook_32.png' & 'facebook_32_off.png' $(".social32").each(function(){ var t=$(this); var src1= $(this)...

JavaScript, asp.net and Sql Server

I know how to use client side JavaScript with asp.net script. But I am unable to figure out how to retrieve data from database and show that data with JavaScript in an asp.net page. Suppose I have written a JavaScript Grid. Then how can I fill that grid with data from SQL Server and show that grid on an asp.net page? That is, how to co...

Resetting/clearing form data, focusing radio button

Hello folks. I am new to all of this so please be gentle! Ok, currently I have the following scenario. I have three methods of searching for product details: A cascading drop down list (ddlbuyer, ddlSub, ddlProd) and an associated radiobutton (radProd) An autocomplete textbox that searches for product information (txtPrdAC) A produc...

Server side Javascript best practices?

We have a CMS built on Java and it has Mozilla Rhino for the server side JS. At the moment the JS code base is small but growing. Before it is too late and code has become a horrible mess I want to introduce some best practices and coding style. Obviously the name space control is pretty important. But how about other best practices - e...