javascript

gwt seperate modules with no code sharing

Hi, I have to make a web application using GWT. The project has a core module that'll expose a set of apis to be used by other apps; each of these app are unrelated. Each shall be loaded in a separate iframe. My idea was to compile core into core.js and each app shall have its own app1.js app2.js and so on... App1 script type="text/...

jQuery: Any way to "refresh" event handlers?

I have two divs, one that holds some stuff and the other with all possible stuff. Clicking on one of the divs will transfer items to the other div. The code I came up with is: $("#holder > *").each(function() { $(this).click(function(e) { $(this).remove(); $("#bucket").append(this); }); }); $("#bucket > *").each...

Using eval() in Javascript to unpack the array

I have an array that I need to unpack. So, from something like var params = new Array(); params.push("var1"); params.push("var2"); I need to have something like "var1", "var2". I tried using eval, but eval() gives me something like var1, var2...i don't want to insert quotes myself as the vars passed can be integers, or other type...

How to add on to an existing onclick event?

I'm currently writing a Greasemonkey script for a page, so I can't modify the script myself. There is a form submit button on the page. When you click this button, it executes some fancy AJAX calls and such to update the page and do serverside things. What I'm trying to is basically set a "lastClick" value when the button is clicked. ...

Get Degrees (0-360) from One LatLng to Another in JavaScript

Can someone help me fill in the blanks with native JavaScript? function getHeading(lat1, lon1, lat2, lon2) { // Do cool things with math here return heading; // Should be a number between 0 and 360 } I've been messing around with this for a long time and can't seem to get my code to work right. ...

jQuery won't parse xml with nodes called option

hi all, I'm using jQuery to parse some XML, like so: function enumOptions(xml) { $(xml).find("animal").each(function(){ alert($(this).text()); }); } enumOptions("<root><animal>cow</animal><animal>squirrel</animal></root>"); This works great. However if I try and look for nodes called "option" then it doesn't work: fu...

Selections and radioing - JavaScript

I have a list like this: <ul> <li id="adm-thumb" onclick="javascript:addBanner('bowling.jpg');"> <div class="adm-tick"></div> <img src="img/banners/bowling.jpg" /></li> <li id="adm-thumb" onclick="javascript:addBanner('kcc.jpg');"> <div class="adm-tick"></div> <img src="img/banners/kcc.jpg" /></li> ...

set the focus on the scroller when button is clicked

hi i have a script <script type="text/javascript"> window.addEvent('domready', function(){ var totIncrement = 0; var increment = 560; var maxRightIncrement = increment*(-6); var fx = new Fx.Style('slider-list', 'margin-left', { duration: 1000, transition: Fx.Transitio...

Using javascript to print images

Hi all, I would like to know if it's possible to use javascript to open a popup window containing an image, and at the same time have the print dialog show. Once someone clicks on print, the popup closes. Is this easily attainable? ...

My Optin form doesn't work in Internet Explorer, but works fine in Firefox.

I have the following code for my optin form: <script language="JavaScript"> function checkSub() { if (document.signup.email.value.indexOf('@', 0) == -1) { alert("Please fill in your valid Email address.\nYour email should be in the following format: [email protected]"); document.signup.email.focus(); return f...

Can you determine if Chrome is in incognito mode via a script?

Is it possible to determine if Google Chrome is in incognito mode via a script? Edit: I actually meant is it possible via user-script, but the answers assume JavaScript is running on a web page. I've re-asked the question here in regards to user scripts. ...

What was the name of that interactive jQuery wizard plugin?

Hello, a few weeks or months ago a (I think jQuery plugin) wizard was released, which allows you to do interactive "tutorials". You were able to create interactive boxes which relates to html elements and you were able to change to color of these boxes to red. It's also possible that it was "just" a javascript script and not a jquery pl...

Best way to simplify this code, more efficient

My question is, is there a way to make this code more efficient or write it in a simple way? javascript by the way. switch (tempvar1) { case 1: currentSlide = 'slide1'; showaslide('ppslide1'); break; case 2: currentSlide = 'slide2'; showaslide('ppslide2'); break; case 3: currentSlide = 'slide3'; sho...

Javascript search for all occurences of a character in the dom?

I would like to find all occurrence of the $ character in the dom, how is this done? ...

Help! How to get the event handler with IE Dom interfaces?

Hey Gurus, I am working to use IE Dom interface to automate IE page access. I am trying to get all event handlers defined in a page. I am using IHTMLElement object now for this purpose. If the html page defines "onclick=xxx", element.onclick returns the click handler. However, if an event handler is defined in javascript, element.oncl...

JavaScript alert title header

I want to change JavaScript alert title header from displaying Internet Explorer to another name. is a way to do it? I found these site in the net: http://bytes.com/topic/javascript/answers/148721-change-title-bar-javascript-alert-box http://stackoverflow.com/questions/1905289/how-to-edit-a-javascript-alert-box-title Which say that t...

Jquery Ignore Event

Let's say we have this markup: <span href="">Text <a href="">Link</a></span> We have events bound to both elements. How do I make it such that when I click on the anchor tag, the event on the parent will not be triggered? I've tried using the Jquery method stopPropagation() but still no luck. Any thoughts? Thanks. ...

How to match "input" and "select" elements in jQuery with 1 query

re, I have a simple query that works: $("#test > fieldset > input").each(function() { }) However, I want to select "input" and "select" elements without having to write 2 "each" queries. Is this possible? thanks. ...

Howto - JavaScript Replace which finds all instances not just the first

I have the following function: listorder = listorder.replace('projectlist-',''); Problem with this is it only finds and replace the first instance and there are many. How can this be updated to Find/Replace All instances in the string? Thanks ...

Infinite Refresh Loop in Firefox 3.0

I'm having a strange issue with my Javascript in Firefox 3.0.x. In Firefox 3.0.12, the page constantly reloads as soon as the list body is loaded. Neither Firefox 3.5, Safari 4 nor Chrome 5 (all on Mac) experience this issue. EDIT: I've created an isolated example rather than pulling this from my existing code. The issue was related t...