javascript

Should I use the YUI Compressor or the new Google Closure compiler to compress my JavaScript?

YUI Compressor was the consensus best tool for minimizing, but Closure seems like it could be better. ...

window.open broken on FireFox with Google Toolbar installed

Just now I started having problems with a site I'm working on. The problem occurs when opening a window with a simple window.open. var popup = window.open("picture.php?id="+id, "gallerypicture", "width=737, height=543, top="+top+", left="+left); popup.focus(); For some reason Google Toolbar starts breaking stuff as soon as the wi...

Is it possible to upload image to server without submitting the form?

I have a file field in my form. I want the user to be able to choose an image, press OK, and then without submitting the form, preview the image in a smaller resized way. If everything is to the satisfactory of the user, then hit submit and the image as well as the form is submitted... How would you good professionals do this basically...

How can i get the destination url in javascript onbeforeunload event?

I've searched for hours, but I couldn't find a solution for this. window.onbeforeunload = warn; This doesn't work: function warn (e) { var destination = e.href; alert(destination ); } Okay, so to clear the things. If the user clicks on a link on the page itself, it is easy, because you can add an eventhandler to all of the ...

javascript variable reference/alias

is it possibile in javascript to assign an alias/refrence to a local var someway ? I mean something C-like: function foo() { var x = 1; var y = &x; y++; alert(x); // prints 2 } = EDIT = Is it possibile to alias arguments.callee in this code?: function foo() { arguments.callee.myStaticVar = arguments.callee.myStaticVar ||...

Reloading Content of Ajax Tab

I'm completely puzzled, I make an ajax call inside a Jquery UI Tab, after that I want to refresh the content of the tab, the function that should be doing it is: function reloadTab(){ var $tabs = $('#tabs').tabs(); var selected = $tabs.tabs('option', 'selected'); $tabs.tabs('load', selected); return false; } Incredible but true it do...

What is DOM Event delegation?

Update Can anyone please explain event delegation in JavaScript and how is it useful? Original: Delegation in programming. Can anyone please explain delegation and how is it useful? ...

Another GMap Problem

I have been looking over this code for the past hour, I cant see why html pop up will not show, I'm probably missing something simple as no errors are reported. var map; var markers = new Array(); var geocoder; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.setCenter(new G...

How to call C++ functions/methods via JavaScript

Hi, does anybody know how to call C++ functions or methods via JavaScript. Need scripting like Lua/Python-C++ but with JavaScript. Thanks in advance. ...

<textarea> what key was pressed with javascript

Hello! I would like to ask somebody how i can determine what key was pressed in a textarea.... need to write a little javascript code.. a user type in a textarea and i need to write it in a while he writing so the keydown, keypress event handle this functionality, also need to change the text color if a user typed a "watched" word (or t...

How to update some part of the webpage?

I would like to update (change the content) some part of the webpage without updating the whole page (without refreshing the page). Of course first thing you would write as an answer will be "Ajax!!!", but I know that search engines will not be able to get the content of that part if I do with Ajax. So is there any method or workaround ...

Problem targetting only specified element

I've been working on a small jQuery plugin that creates an iPhoto-like preview when hovering over images. It all works great if I only have one set of images. As soon as I add more than one .preview set to the markup my plugin finds all of them and displays the total amount of indicators below each image. Here is the JS: $(document).re...

sorting elements javascript

I'm looking for a way to sort my elements, but it isn't as easy as it sounds. Please let me explain My elements are grouped per 6 elements (thumbnails), each x represents a thumbnail However all thumbnails are inside one div xx xx xx xx xx xx xx xx xx The first column (6 x's) is visible and when you click on a button the ...

\n newline character won't work with Javascript

I need to put different information in separate lines, I have a working Javascript library, but I can't force the text output to display a newline. Here is the relevant part of the Javascript: var information = layer.objectAdd({ type:"tooltip", clickable: true, Title: "My title", Description: "My description1 ...

How can I do a MouseOver of exact image shape?

Hello all, The question below is not really a programming question, but more of "how can I do this" question, implementation advice. I have an image of the world map. I can make each continent a separate image. What I want to do is create a hover over feature for each continent. When the users mouse is over the continent - the EXACT s...

javascript if alternative

what does this bit of code represent? I know its some kind of if alternative syntax .. pattern.Gotoccurance.score != null ? pattern.Gotoccurance.score : '0' tnx QUESTION UPDATE : why need for this sort of coding, is this more efficient or just shortened version with same efficiency? ...

Tell from where a .php file has been included?

Does anybody know of an automated way of telling whether a PHP script is being called directly (as a HTML page), or as a JavaScript, or as a CSS Stylesheet? Without GET variables, or setting a flag in the file ( that is what I am doing right now). Just curious. EDIT: Some background because it was asked for in answers: The reason why...

Where is arguments property defined?

Consider the following code function add(x, y) { alert(arguments.length); var total = x + y; return total; } add(); // NaN alerts 0 add(2,3); // 5 alerts 2 add(3,3,5); //6 alerts 3 Where is arguments defined? How come it is available inside my add function? ...

div tag for popup menu

Hi, I add a div tag and append it to the body and then i add to add items to the div so that it becomes a popup menu. After appending the to body, is there a way to move the div tag. Actually what i want to do is that i want the div to appear wherever the mouse was clicked on the webpage. By the way i am developing a firefox extension....

Jquery Listbox / Textbox filter

Hi, I have the following jquery function for filtering the contents of a listbox on the onkeyup event from a textbox. function DoListBoxFilter(listBoxSelector, filter, keys, values) { var list = $(listBoxSelector); var selectBase = '<option value="{0}">{1}</option>'; list.empty(); for (i = 0; i < values.length; ++i) {...