javascript

execute javascript method after completing code behind method ?

I want execute below callback() method after completion of document.getElementById('btnDownload').click(); method . Now callback()executing immediatly. I want wait "Click()" process done then Execute callback(); method. function LoadPopup() { // find the popup behavior this._popup = $find('mdlPopup'); // show t...

Is it possible to capture mouse events on a scroll bar in JavaScript

I have an HTML element with overflow: scroll. The click event listener registered with the element is triggered when I click on the element, but not when I click on the scroll bar for the element. Is it possible to capture mouse events which occur on an HTML element's scroll bar? The reason I want to do this is to make a visual popup el...

Determine an elements position in a variable length grid of elements

I have a grid of a variable number of elements. Say 5 images per row and a variable number of images. I need to determine which column (for lack of a better word) each image is in... i.e. 1, 2, 3, 4 or 5. In this grid, images 1, 6, 12 and 17 would be in column 1 while 4, 9 and 15 would be in column 4. 1 2 3 4 5 6 7 8 9 10 12 ...

JavaScript - Passing a reference to this current anonymous function

window.addEventListener('unload', function(e) { MyClass.shutdown(); window.removeEventListener('unload', /* how to refer to this function? */); }, false); ...

Quick Look at Objects in Rhino Shell (PHP var_dump equivalent?)

Is there a better way of debugging in Rhino than typing this everytime? : for (prop in obj) { print("obj[" + prop + "] = " + obj[prop]); }; Update: To be clear, my question is whether there are any existing standard practices/modules/tricks on this topic. ...

How can I get contentWindow for an Object element in IE7

I have a HTML object element like this: <object title="Search results as XML" standby="Loading XML document..." type="text/xml" data="/__CA25761100195585.nsf/WebPrintListingXML?OpenAgent&date1=01/06/2009" width="100%" height="100%" border="0" name="resultIFrame" id="resultIFrame"> Error: could not embed search results. </object> I also ...

jQuery + External javascript: How to embed videoplayer in div

I just started with jQuery and so far I have a really good impression of the framework. But now I have a problem that I can't figure out on myself. I want to embed an external javascript file that loads a videoplayer and displays it. If I include the <script>...</script> directly in HTML it loads just fine. But when I try to load it with...

javascript highlight text(IE7/8) Issue

Hi its a browser(IE) issue i have a code and its does highlight on selected text....its working fine but when i m selecting text that already selected then its not highlighted(Selected) on IE7/8 plz see code below if (window.getSelection) //Firefox { range = window.getSelection().getRangeAt(0); var sel = window.get...

checkbox value after refresh

hi guys, How to retain the checkbox value (in js) after refresh? There is a checkbox in this form. When the page is refreshed, the checkbox data disappears. Is there a way to refresh the page, while keeping the checkbox data? I have a window (#1) with a form and checkbox. #1 has a link to pop up another window (#2) with another form. W...

split with javascript

Hi below is something I am trying to do with JavaScript. If I have string like str = "how are you? hope you are doing good" ; now I want to split it with ? (or . or !) but I dont want to lose the "?". Instead I want to break the string just after the question mark such a way that question mark is with the first segment that we hav...

Hide table rows except head

Without Jquery or any JavaScript library i need to hide the rows of a simple html table except for the table head on page load. ...

jQuery .toggle() called by window.setInterval() not functioning

I am trying to alternate between two logos every 5 seconds using the following code: window.setInterval( function () { //breakpoint 1 $("#logo").toggle( function() { //breakpoint 2 $(this).attr('src', '/Images/logo1.png'); }, function() { ...

jQuery - .Ready fires on div tag not in the page

Dear all, I have implemented below function in a separate .js script file which I load in my main page (Asp.net mvc). The call back to server is rather costly but ok if specifically requested on the sub-page / content page on which my div tag needs to be filled. My problem is that the code runs on every page, including pages where the...

Invalid Label Error with JSON request

I've read about this a lot and I just can't figure it out. It has nothing to do with MY code, it has to do with the feed or something because if I swap it with a Twitter feed it returns an Object object which is perfect. $.getJSON('http://rockbottom.nozzlmedia.com:8000/api/portland/?count=1&amp;callback=?',function(json){ console.lo...

How can I read the HTML contents of the file which contains a button

Folks, I have a HTML file which contains a button called "Email this content to me". Upon pressing this button, I want the complete HTML content of the file to be emailed to me. Can someone tell me if there is a javascript function to do that. A short example would go a long way :) Thanks in advance ...

Which is the most accurate way to check variables type JavaScript?

I need to check the type of a variable in JavaScript. I know 3 ways to do it: instanceof operator: if(a instanceof Function) typeof operator: if(typeof a=="function" toString method (jQuery uses this): Object.prototype.toString.call(a) == "[object Function]" Which is the most accurate way to do type checking beetween these solutions?...

Scrolling to the bottom of a div on page load: issue with syntaxhighlighter

I've been using this code: var objDiv = document.getElementById("code"); objDiv.scrollTop = objDiv.scrollHeight; to scroll to the very bottom of the div. It worked perfectly in FF and Chrome (I asked a question about it not working in Chrome a few days ago, but it appears the guy who was testing it on Chrome was incorrect, so I tested...

Same widget code on page

Hello, I'm creating a widget using jQuery. It's a charting widget which communicates with the server (PHP) through ajax to update the chart. My problem is that I need 2 of this widget on the same page without one overwriting the other. How can I encapsulate the javascript code without using the same code twice and without defining sepa...

Determining when scrolled to bottom of a page with Javascript

I'm trying to determine when I've scrolled to the bottom of the page (without using any JS library), but so far, I'm a bit confused over which one of the following to use. The most promising one I've seen is window.scrollY, but even when scrolled to the bottom of the page, it never matches the value of window.innerHeight. What's the be...

Why doesn't this work? jquery javascript

$(document).ready(function() { musicList = new array() counter = 0; if($(".rA, .trA, .dA, .hA").length > 0) { /*$(".rA, .trA, .dA, .hA").each(function(e){*/ $(".hA").each(function(e){ $.post("/index/audio/ajax.track", { id: $(this).attr("rel") }, function(data){ /*THIS DOE...