javascript

Are events lost in jQuery when you remove() an element and append() it elsewhere?

What happens in jQuery when you remove() an element and append() it elsewhere? It appears that the events are unhooked - as if you were just inserting fresh html (which I guess is what happening). But its also possible my code has a bug in it - so I just wanted to verify this behavior before I continue. If this is the case - are there...

Best practice for using window.onload

I develop Joomla websites/components/modules and plugins and every so often I require the ability to use JavaScript that triggers an event when the page is loaded. Most of the time this is done using the window.onload function. My question is: Is this the best way to trigger JavaScript events on the page loading or is there a better...

Javascript syntax errors in IE

I have created a fairly large Javascript app that works in Firefox and up until yesterday, IE. I've made quite a few changes and now I'm getting syntax errors in IE, but all is fine in Firefox. Obviously I have a trailing comma somewhere but I can't see it. IE's error message is less than helpful, not even telling me which JS file has th...

Correct way to pass a variable from the server backend to javascript?

I need to pass a variable that php is aware of to my javascript code and I'm wondering what the correct way to do this is. I already know that I could add this to the page generation: <script type="text/javascript"> var someJSVariable = <?php echo $somePHPVariable ?> </script> But I find this method to be more obtrusive than I'd like...

jQuery JSON Problem...

I want to populate form fields with values from a database immediately after the user enters a value in the #sid field. Here is my jQuery/HTML example: <script src="jquery-1.3.1.min.js"></script> <script type="text/JavaScript"> $(document).ready(function() { $('#sid').bind("change", function(){ $.getJSON("test.php?sid=" + $("#sid...

Why would this javascript not work in IE7 or Safari?

Firefox handles it fine, but Safari and IE7 silently fail and do not insert the element. <script type="text/javascript"> var ul = document.getElementById('xg_navigation').getElementsByTagName('ul')[0]; ul.innerHTML = '<li id="xg_tab_home" class="xg_subtab"><a href="http://somedomain.com/"&gt;Some Text</a></li>' + ul.innerHTML; </scr...

self.close() not working for mozilla

self.close() working fine in IE but not in Mozilla, anyone know what to coused this issue? and how can I solve it? ...

Is getting JSON data with jQuery safe?

JSON allows you to retrieve data in multiple formats from an AJAX call. For example: $.get(sourceUrl, data, callBack, 'json'); could be used to get and parse JSON code from sourceUrl. JSON is the simply JavaScript code used to describe data. This could be evaled by a JavaScript interpreter to get a data structure back. It's genera...

single quotes versus double quotes in js

Hi, Are there any differences between single and double quotes in javascript? ...

what is the reserved keyword for NaN in javascript?

if i want to test the result of an expression and the function would return NaN how would i check that? examples: $('amount').value.toInt()!='NaN' ^ does not work and i assume that the returned value is not a string, $('amount').value.toInt()!=NaN^ doesnt seem to work either and this one seems obvious so how do i check wether the returne...

Why can't I use multiple ids here?

I'm trying to get a bit of code working. I'm using xfade, latest version. Homebrew Javascript image fader that fades between all img tags in a div, assigned by the Javascript. There's an image fade script I found that uses Javascript to fade between images in a div. However, it can only fade 1 div...I have 3 spots I want to have fading i...

Javascript to access control in MasterPage

I have a textbox control Super1 in my MasterPage. I am using javascript to access this control from my content page like this: <asp:Content ID="ContentPage" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <script type="text/javascript"> function Somethin() { { document.forms[0].elements['Super1'].valu...

How to access programmatically to a style sheet in webkit engine (Chrome/Safari)

In IE with document.getElementById("css_id").styleSheet or in Firefox document.getElementById("css_id").sheet I've a style sheet object to manipulate but in Chrome and Safari browser that property there is not. How can I get that object? Thanks ...

Web production: Absolute URLs in external JS files?

Hi guys, I was wondering, are you aware of any best practice for specifying absolute URLs in external javascript files? I'm looking for a maintainable solution. The basic scenario is when i need to include css files at run-time through javascript, or make ajax calls to some URL, and other situations where you would normally need to spe...

ASP generated javascript

Hi, I'm wondering if someone can point me in the right direction. I've got an ASP.NET web application. And there's autogenerated portion of JavaScript in every page that handles postback. Sometimes that javascript is surrounded by <[CDATA[ ... ]]> , while on the other machine it may be enclosed in simple HTML comment like <!-- .....

Calling base method using javascript prototype

Is it possible to call the base method from a prototype method in javascript if it's been overridden? MyClass = function(name){ this.name = name; this.do = function(){ //do somthing }; }; MyClass.prototype.do = function(){ if (this.name === 'something'){ //do something new }else{ //CALL BASE METH...

Is it possible / recommendable sending HTML emails containing Javascript?

This is mostly a rhetorical question, as far as I've checked the answer is 'don't even bother', but I wanted to be really sure. We have an email app, where you can send email to lists of subscribers. This is not spam: it's used, for example, by an university to send communications to its students, by a museum to send emails to subscribe...

jQuery queue events

So what I want to do is to coordinate some effects using jQuery for some AJAX calls that I'm working with. My problem is that the fadeIn for the second div fires at the same time with the fadeOut for the first div. This could apply to other events as well so I'm curious, is there any way to make fadeId launch ONLY after fadeOut is done ...

jquery wait cursor while loading html in div

I want to show to the user a state that the result is loading. How can I change cursor or gif while loading result in div with $MyDiv.load("page.php") ? ...

JavaScriptResult in asp.net mvc RC1

Why do you need JavaScriptResult as a response? Doesn’t it break the pattern of clean separation of concerns? Can you suggest me some cases where this will be useful? ...