javascript

jQuery Javascript scrollTop not working as expected on Chrome to restore scrollbar position

I'm using the following jQuery Javascript to save the scrollbar position before the unload event and reapply it again: $(document).ready(function () { document.documentElement.scrollTop = $.cookie("scroll") || 0; }); window.onbeforeunload = function () { $.cookie("scroll", document.documentElement.scrollTop, { expires: 7 }); } ...

javascript event for attachment downloaded?

hi there i have a page that generates a report, the report is sent to the browser as an attachment. what i would like to do is .. disable the generate report button , or show a spinny please wait, and when the attachment has finished being generated and has been sent to the browser i'd like to remove the spinny logo/re-enable the button...

jQuery dynamicly change onlick location.href

This works in firefox but doesn't do anything in IE: $("#_results").autocomplete({ source: data, minLength: 0, select: function(event, ui) { $("#log").empty(); log(ui.item.lname + ", " + ui.item.fname + " " + ui.item.sso); ...

jquery-ui close dialog

I have a little problem closing my dialog box in javscript/jquery on mouse exit here is the script $().ready(function () { $(".popup").live("mouseover", function () { $(this).next().dialog(); }); $(".popup").live("mouseout", function () { $(this).next().close(); }); }); ...

javascript elements is undefined

When I load vote.php on my web browser instead of index.php, I was able to vote and display user statistic. However I decided to implement the poll system by adding include('vote.php') to index.php, my document.forms[0] from vote.js can detect how many radio buttons in vote.php but I having problem getting this code working that appear t...

Is the following JavaScript construct called a Closure?

(function() { //do stuff })(); EDIT: I originally thought this construct was called a closure - not that the effect that it caused results (potentially) in a closure - if variables are captured. This is in no way to do with the behaviour of closures themselves - this I understand fully and was not what was being asked. ...

Converting a string

How do I convert a string This: file:///C://Program%20Files//Microsoft%20Office//OFFICE11//EXCEL.EXE To this: C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE ...

onkey event - problem with disabled button

Hi, Explanation: At the beginning the value of the field is YYYY-MM-DD. if the user delete the value and doesn't type anything, the button "ok" should be disabled. if the user delete the value and type new value, the button "ok" should be enable. The code is working only for the second case. function ChangeOkButton() { if(docum...

Clustering in Google Maps

Hi all, I have developed an application using google maps v3. Here, I need to show some markers at the initial zoom level. The problem is on mouseover of the marker, I need to show a div content. The div is not properly aligned, that is for the marker on the extreme left or right, the div is getting partly hidden. How do I show the div w...

Loadin CSS dynamically - jQuery vs plain Javascript

Hi, I'm loading CSS file in java script code. At first I used jQuery code. It worked fine, but after somet time I realized that CSS rules are not applied in IE browser. So I googled and replaced it with document.createElement version. Now it works smoothly in all browsers. Anybody knows why? Is there a difference in those two approaches...

Determine value of encapsulated javascript function parameters

Alright, to start with let's look at some code: <html> <body> <script type="text/javascript"> function logFunction(fn) { console.log(fn.prototype); console.log(fn); console.log(fn(4)); } var num = 5; var add5 = function(x) { retur...

Changing Object Parameter Names On-The-Fly

If I have the following: var myObj = { "Foo":{"prop1":"abc", "prop2":123 }, "Bar":{"prop1":"def", "prop2":456 } }; Is there a quick and safe way to modify the object such that it becomes: { "Foo":{"prop1":"abc", "prop2":123 }, "Bar":{"PROP1":"def", "PROP2":456 } } I'd like to change the casing of the property names of the Bar prope...

File Upload input control's onchange event bug in CHROME

Hi, I am having fileupload control having its "multiple" attribute equals to "multiple". I am facing a weird issue in CHROME browser. The isse is that onchange event of file upload control is not firing for more than 12 files selected at once. The event is firing if I have 10 files selected at once. On FF and Safari it is working fine. ...

How do I update the JavaScript this-pointer inside an object to point to another object?

hi guys, I'm having some trouble with JavaScript and the passing of a function as parameter of another function. let's say we are inside a class and do something like that: this.get('target').update(this.onSuccess, this.onFail); 'target' is a JavaScript-object that has a method called update() I'm calling this method and pass tow me...

<textarea> scrollHeight is comming zero on body load

Hi I wanted to get <textarea> scrollHeight on body load using jquery. It's always getting zero. I want actual height of textarea on body load. If it's not possible to get scrollheight on body load, is ther any way to get actual height rather than height(). Please suggest if you have any reference. Thanks -Pravin ...

javascript - capture input and convert characters

I want to capture input charcters in text box, convert then according to a table and put them back in text box as user types. <form id='myForm'> Enter phone number:<input type="text" id='idMyText' name="myText" onKeyUp="alphaToNum(this.value)"> </form> <script> // on each keypress in input box, I want to capture key pressed, // det...

On page load jquery

I have a jQuery click event which runs when an element is clicked. Is it possible to get this to run once when the page is loaded? ...

How to write javaScript function for this ?

I have a textbox and i write javascript function that if it is blank then it will generate alertbox . but i press space in that textbox then it doesnot generate alertbox. so i want that if i give space then it also generate alertbox, for this what to do? I used this function: function Trim(objValue) { var lRegExp = /^\s+/; var...

How can I add callbacks to jquery validation (when used in MVC 2)

I'm using jquery for validation in my MVC2 web app (as described here) and I'd like to wire up some callbacks that the jquery validation plugin supports, like invalidHandler, etc. I can manually edit the MicrosoftMvcJQueryValidation.js and add my callbacks (in __MVC_EnableClientValidation, in the options variable) but I was looking for ...

How to disable Firefox's default drag and drop on all images behavior with jQuery?

Firefox has this annoying behavior that it let's the user drag and drop any image element by default. How can I cleanly disable this default behavior with jQuery? ...