javascript

Does javascript still allocate memory for the "IF" scenario if the condition evaluates to false?

Soooooooooooooooo... I have an IF statement that nowadays will evaluate to true 99.7% of the time, which consists of a check to see if the browser is DOM 1+ capable, and then load a big block of code. So it's logical to put an "if (true)", and omit the "else" part, but i wonder if the older browsers will still continue to parse the co...

[Javascript] Search and replace all elements

Hello all, I need script to append text or delete all matched elements if there are any in textarea. I tried this: http://pastie.org/789631 What's wrong there? Thanks. ...

Change encoding from UTF-8 to ISO-8859-2 in Javascript

I would like to change string encoding from UTF-8 to ISO-8859-2 in Javascript. How can I do it? I need it because I've designed a widget. User just copies < script > tag from my site and puts it on his. This script creates div and puts into div widget contents with text. If target website is in UTF-8 encoding - it works fine. But when ...

How to show live preview in a small popup of linked page on mouse over on link ?

How to show live preview in a small popup of linked page on mouse over on link ? like this http://cssglobe.com/lab/tooltip/03/ but live preview ...

What are cons to use sIFR, in terms of , development time, accessibility, speed and mobile devices?

What are cons to use sIFR, in terms of , development time, accessibility, speed and mobile devices? Some cons Which i know. Rendering speed of pages will be slow because of it use JavaScript and FLASH both sIFR text will not be shown in Iphone safari and blackberry. and if it will be shown in other mobile browsers then browsing will b...

How can I delete jquery object at runtime?

$("#id").tooltip({ effect: "slide", tip: '.tooltip' }); I want to delete the object created by this code. "flowplayer jquery tools" plugin This question has an answer described in the bottom of my post! See the bottom if you don't wanna loose you time . ----------UPDATE---------- That should be somethi...

Adding amount to background-position on click (jQuery)

Hey, I pretty new to js and jquery so please bear with me. I'd like to change the background-position and add 1% on #div1 while clicking on #button1 and take -1% on #div1 while clicking on #button2 How could i achive this in jQuery? Alse, bonus question: These are going to get dynamically generated through php. Is it possible to use ...

subclass.prototype = new superclass() vs. subclass = new superclass()

I've been instantiating subclasses in javascript using object = new class () but I notice some people instantiate using object.prototype = new class () Question: What's the difference? To me it seems like the latter is respecting the inheritance chain more because if class () has a bunch of "this.variable = x" statements, and objec...

Organising JavaScript / jQuery - alternative to using jQuery's live hookup

Hi, Simple question (I hope). I have a page that contains links that when clicked loads up new content into a specified div. The content that gets loaded (a partial view) contains further links that fire JavaScript code (jQuery). I have been hooking these links up using jQuery's live system. It has been recommended to me that I wire-up...

JavaScript / ExtJs : TreePanel / TreeLoader : how to handle load errors?

Almost everything is in the title ;) When you create a TreePanel you can add a loader this way: loader: new Ext.tree.TreeLoader({ dataUrl: '../myurl.php' }); But how to handle load errors? For example if the user is not connected I want to display a Login box. I can't find an example showing how to handle loading errors with Tree...

Using Prototype to load a JavaScript file from another domain

Using Prototype, anyone know how to load a javascript file using Ajax.Request from another domain? Or if this is possible? I believe this is possible with jquery, digg do it to load the Facebook API: jQuery.ajax({type:"GET", url:"http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php", cache:true, dataType:"script"}); Sou...

How does this mess work?

My Joomla! website has been repeatedly hacked into. Someone, somehow, managed to inject the following rubbish into the key php scripts, but I mean not to talk about configuring Joomla. The site is not visited much (at times I fear I might be the only visitor to that site...) and I don't care much to have the site back up and running. I'l...

HTML 5 File API

I hear that Firefox 3.6 adds support for the HTML local file API (Announcement here). Does this mean that I can access local files from javascript? Can anyone point me to examples for reading / writing local files? I would love to be able to read / write simple text files. Many thanks ...

Javascript,calling child window function from opener doesn't work

Hello! I'm developing a web application that opens a popup using windows.open(..). I need to call a function on the opened window using the handle returned by "window.open", but I'm always getting the error message "addWindow.getMaskElements is not a function", as if it couldn't access the function declared on child window. This is the b...

jQuery toggle();

Hi I am loading data dynamically by AJAX into a cluetip (http://plugins.learningjquery.com/cluetip/#). I want to toggle the results from a link like so: $(document).ready(function() { $("#calendarLink").live("click",( function() { $("#result").toggle(); })); }); For some reason the above will not work. Can you sugg...

Is it considered bad practice to use non-standard HTML attributes?

I find it very convenient to set arbitary attributes like: <a stackoverflowId="123">...</a> And in JavaScript: var soId = $selectofA.attr('stackoverflowId'); //jQuery Is it a good practice at all? I've never had a problem with this yet. ...

Preventing jQuery from Loading

If jquery is added in globally used header.php across the site then How to stop to load jquery library only for those pages of site which doesn't need actually? If we can't use more than one header. purpose of question is to not to penalize those page with slow loading which actually don't need. ...

Is there a better way to write this jQuery script?

So the script works, but it seems pretty long. I think there may be some shortcuts I could take, maybe use an array? But I'm new at JS, and really new at jQuery. What it does: I have a list of ten questions, and I want to take a graphic (plus sign) and toggle it when clicked to a minus sign. It will also reveal the answer by using a sl...

Images In Javascript

Hi All, I am creating a small application where there are multiple images displayed and when user clicks on any one of the images it gets bigger and replaces the image that is in middle. But I am not getting the clicked image. <HTML> <HEAD> <SCRIPT LANGUAGE="text/javascript"> function swapImage(this.id) { document.write("In SwapImage"...

Why does reduceRight return NaN in Javascript?

I'm using Firefox 3.5.7 and within Firebug I'm trying to test the array.reduceRight function, it works for simple arrays but when I try something like that I get a NaN. Why? >>> var details = [{score : 1}, {score: 2}, {score: 3}]; >>> details [Object score=1, Object score=2, Object score=3] >>> details.reduceRight(function(x, y) {return...