javascript-events

JavaScript function is not defined

Consider: File script.js, function AdaugaComboBox(id, name){ var select_tag = document.getElementById(id); select_tag.innerHTML += "<select name='"+name+"'><option value='0'>Selecteaza autor</option></select><br/>"; return true; } and file index.html: <html> <head> <script src="js/script.j...

Help, "this" is confusing me in JavaScript

Working with the JavaScript one of the confusing thing is when using this var x = { ele : 'test', init : function(){ alert(this.ele); } } However when dealing with multiple object and especially events context of this changes and becomes confusing to keep track/understand. So if anybody has better inputs/guidelines/thoug...

Parse string for text between divs

I have a string of html text stored in a variable: var msg = '<div class="title">Alert</div><div class="message">New user just joined</div>' I would like to know how I can filter out "New user just joined" from the above variable in jQuery/Javascript so that I can set the document title to just the message. Thank you. ...

What's the best way to keep track of live notifications to send to a user?

I'm using a growl-like plugin for jQuery send live messages to users to share activity on the site. Right now I only update the user with notifications that happened since the user's last access on the site. However, when I have multiple tabs open on the site, only some of the tabs get the notifications due to the long polling requests...

Change css class when validation fails

Hi there, I'm having a issue with validations on my aspx page; I have the following code: <td> Id </td> <td> <asp:TextBox ID="txtId" runat="server"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="reqId" runat="server" ErrorMessage="Error" ControlToValidate="txtId" SetFocusOnError="true"></asp:RequiredFieldVa...

Fire Javascript Event When a DIV is in View

Is it possible to fire a specific javascript event when a certain DIV comes into view on the page? Say, for example, I have a very large page, like 2500x2500 and I have a 40x40 div that sits at position 1980x1250. The div is not necessarily manually positioned, it could be there due to the content pushing it there. Now, is it possible ...

Handle URL anchor change event in js

How can I write the JavaScript callback code that will be executed on any changes in the URL anchor? For example from http://example.com#a to http://example.com#b ...

Redirect from iframe to the new window

Hello everybody. I have been building widget that accept user input and then once everything checked it will redirect user to the original web site. However the best I achieved for now is that redirect will be opened in parent window rather then in new window. Right now I am using $(parent.location).attr('href', asoRequestURL); Ho...

Unable to change global variable from local function

I'm trying to have a jQuery.getJSON() call change a global variable with the JSON array it returns var photo_info ; //Advance to the next image function changeImage(direction) { jQuery('img#preview_image').fadeOut('fast'); jQuery('#photo_main').css('width','740px'); if (direction == 'next') { ...

JavaScript key listener disabled when inside a text form

I have a key listener assigned to the arrow keys to navigate a slideshow. But I want to disable the key listener, temporarily, while a user is typing inside an input field. How can I do that? My current code looks like this: //Listen to the keys function checkKey(e) { switch (e.keyCode) { case 37: changeImage('pre...

Returning data from jQuery ajax request

I'm trying to get a function to perform an ajax query and then return the interpreted JSON as an object. However for whatever reason, once this request is performed, the data is only accessible from within the function. function getCacheImage(direction) { jQuery.ajax({ url: json_request_string, ...

Is there a way to capture x-browser paste events in mootools?

I want to capture when a user pastes data into a text input field using mootools event system. Anyone have experience of this? ...

Javascript window.location search for "#" never returns true

I'm trying to set up a redirector so that when my AJAX functions change the hash part of the URI, the link is still directly accessible should it be copied and pasted. My current function is below; however, it always returns false! //If a hash is found, redirect it var current_uri = String(window.location); if (current_uri...

How can I stop a javascript from being interpreted after a certain point?

The first few lines of my script look like: if (window.location.hash) { window.location = window.location.hash.substring(1); } I'd like to have the entire script "skipped" if this statement returns true. Is there any way to do this other than putting my entire script in a giant if statement? Thanks. ...

jQuery images with fadeIn() don't load when page is cached or accessed via back button

At the beginning of my script, I have: jQuery(function() { jQuery('img.thumbnail').hide().load( function() { jQuery('img.thumbnail').fadeIn(); }); }); Which nicely fades in all the thumbnails on the page as they are loaded. However, when I access the page for a second time (when it is cached), or when I press the back button ...

Javascript Object Inheritence

I'm creating a control for Google maps v2. While creating my control I've found a design challenge and want to find an appropriate solution. Here's the goods. A custom Google control inherits from GControl; myControl.prototype = new GControl(); Next I need to overload the initializer so here it is. myControl.prototype.initilize = f...

asp.net mvc: checkbox onchange not working

I have a page with a set of checkbox's, that I want to run a javascript function on when there is a change (I have done something very similar with dropdown's - and that worked) However with the checkbox's I have three problems: my onChange event only runs "sometimes" (you have to change the focus between the different checkbox contro...

jquery, trigger, bind, strange parameter

Hello, I have the following code: <body> <form> <input type="text"/> </form> <script> $( function () { $(document).bind("EVENT", function (event, element) { console.log("BIND", element, event); }); $("form").each( function iterate(index, element) { ...

dynamically generated Elements are not appended in document correctly in IE.

I have written a Javascript calender, that is dynamically generated by Javascript. But if does not functions in IE. here is the link to my script. http://asexpress.de/calender/ We one looks at IE Developer tool, the newly generated contents are there but do not show in browser. Any help please. ...

Retrigger $().load event in jQuery

Hey. When I want something to happen when an image is loaded I use $("#image").load(function() { something }); but in anything other than Firefox this works only the first time the image gets loaded. For instance if I have made a gallery of images and want something to happen when an image is loaded I use .load and it works the first...