javascript-events

How to get scrollTop of page just after page onload event?

I know how to get the scrollTop of a page, I use this simple JS function (code copied around): function GetScrolledTop() { //I never work in IE quirkmode, I always use DOCTYPE as 1st line, so I don't need to test for document.body.scrollTop return self['pageYOffset'] || document.documentElement.scrollTop; } This works and my p...

Javascript code works only when the page loads

I have a page with a dropdown and two textboxes. The javascript code checks to make sure that if the dropdown says Appointment Made or Patient Scheduled, the appropriate text boxes will have dates in them. When the page loads and the drop down shows either of the two above, all works fine but when I change the drop down the script does n...

Get value of multiselect box using jquery or javascript

In the code below, how to get the values of multiselect box in function val() using jquery or javascript. <script> function val() { //Get values of mutliselect drop down box } $(document).ready(function() { var flag=0; $('#emp').change(function() { var sub=$("OPTION:selected", this).val() if(flag == 1) $('#new_...

i cant call the function in prototype .js ? where i m doing mistake in my code help

Code: DeCheBX = $('MyDiv').insert(new Element('input', { 'type': 'checkbox', 'id': "Img" + obj[i].Nam, 'value': obj[i].IM, 'onClick': SayHi(id) })); document.body.appendChild(DeCheBX); DeImg = $('MyDiv').insert(new Element('img', { 'id': "Imgx" + obj[i].Nam, 'src': obj[i]...

javascript using 'this' in global object

What does 'this' keyword refer to when used in gloabl object? Let's say for instance we have: var SomeGlobalObject = { rendered: true, show: function() { /* I should use 'SomeGlobalObject.rendered' below, otherwise it won't work when called from event scope. But it works when called f...

Jquery: Fade multiple elements one after the other

Hello, is there any possible solution, to fadeIn(500) multiple list elements one after the other? <ul id="list"> <li>test</li> <li>test</li> <li>test</li> <li>test</li> <li>test</li> </ul> Kind Regards, Werner ...

detachEvent not working with named inline functions

I ran into a problem in IE8 today (Note that I only need to support IE) that I can't seem to explain: detachEvent wouldn't work when using a named anonymous function handler. document.getElementById('iframeid').attachEvent("onreadystatechange", function onIframeReadyStateChange() { if (event.srcElement.readyState != "complete") { ...

Dynamic Jquery Accordion

How do I default an accordion to be closed on start-up. here is the sample view here Here is the code: <script> $(function() { $("#accordion").tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide'}); }); </script> <script> // add new effect to the tabs $.tools.tabs.addEffect("slide", function(i, done) { // 1. upon hiding, t...

Catch all DOM events on a page (without Firebug et. al.)

How would I go about creating a cross-browser script, that would intercept all events firing on a page/browser window/DOM-tree (regardless of browser)? What I'm hoping to accomplish is basically to get a better understanding of the different handling of events in different browsers; I know the basic theory, but need to see to believe......

Combining DOM0 and DOM2 event handlers - cancelling of event possible in the DOM0 handler?

Dear expert, please consider the following problem: (1) You have assigned an inline event handler to a DOM element, like so <a id="link1" href="..." onclick=" ... ´"> (2) You also assign one or more further event handler(s) to the onclick event of link1 with the DOM2 or IE-specific assignment mechanism. The verified behavior in FF3.0...

How can I remove an inline onclick attribute with a bookmarklet?

There is an annoying website out there that foils attempts to "open in new tab" by using <div onclick=> instead of <a href=>. I've written a bookmarklet, using jQuery, that creates a wrapper <a> tag and inserts it within the <div> around its content. How can I remove the original onclick handler? ...

Why does a checkbox's "checked" attribute return the opposite of it's actual value on click event?

I've got the following HTML <li><input type="checkbox" /><label>This is the label!</label></li> I bound a click event to the li, and let the click event bubble up to the li before doing anything else. $('li').each(function(i){ var item = $(this); var checkbox = $("input[type='checkbox']", item); item.bind('click', function(e){...

Stop Observing Events with JS Prototype not working with .bind(this)

I'm working on a Javascript class based on the Prototype library. This class needs to observe an event to perform a drag operation (the current drag-drop controls aren't right for this situation), but I'm having problems making it stop observing the events. Here's a sample that causes this problem: var TestClass = Class.create({ in...

jQuery event that triggers after CSS is loaded?

(I posted this on the jQuery forums but it's still awaiting moderation, so I thought I'd try my luck here since Stack Overflow is so awesome. If I get an answer I'll post it here.) I have a couple of links on my page (inside a <div id="theme-selector">) which allow you to change the CSS stylesheets: $('#theme-selector a').click(functio...

How to get the Blur event to fire for the document on the iPhone?

Does anyone know how to get the blur event to fire on the document for the iPhone? I'm trying to get it to fire either when a user changes windows in Safari, or when they open their bookmarks or when they decide to add the page to their homescreen. But none of these are firing it. Here's my code: $(document).blur( function () { ...

What's the cross-browser way to capture all single clicks on a button?

What's the best way to execute a function exactly once every time a button is clicked, regardless of click speed and browser? Simply binding a "click" handler works perfectly in all browsers except IE. In IE, when the user clicks too fast, only "dblclick" fires, so the "click" handler is never executed. Other browsers trigger both eve...

input type text and onKeyDown not working under IE

Hi there. I am writing a WWW application, it has to run under IE. I have the problem with the code that runs under FF, but i can't get it running under IE. // JS code function test() { if (window.event.keyCode == 13) window.location.assign("myPage.php"); } I've tried some similar ways around window.location and location.h...

Scrollbar appear / disappear event in jQuery?

Is there a simple way in jQuery to detect when scrollbars appear and disappear on a div that has overflow:auto? (Like an event? Fingers crossed...) (I'd prefer not to have to look at the height of the content of the div) Thanks! ...

Printing contents of another page

In the following link <a href=\"#\" onclick=javascript:print(\"\") style=\"color:blue;\">Print</a>" <script> function print() { //How to print the contents of another page } ...

Simple command javascript (window.close())

How assure the closing of the window in the firefox with window.close command? ...