javascript

How do I trigger a Javascript function AFTER the page loads?

** EDIT ** I'm afraid I wasn't in the right direction - the problem isn't what I asked about. the Javascript works as it should, it's the PHP that doesn't show what I want it to on the first "run" - and I'm stil not sure why. Sorry for somewhat wasting your time... ** I have a form that might or might not already contain data in its f...

jQuery: What is returned if $('#id') doesn't match anything?

What is returned if $('#id') doesn't match anything? I figured it would be null or false or something similar so I tried checking like so: var item = $('#item'); if (!item){ ... } But that didn't work. ...

retrieve window.location.hash url in php

I am using a jquery tabbed interface here http://www.imashdigital.com/#2 and would like to return the tab number in php. Ideally I would like to run a javascript function (on a timer) that continually updates a global php variable with the current tab. Based on this php value, 1 through to 4, I will then load a different sidebar. I wo...

Javascript event synchronisation

Is there a possible way to synchronize events in javascript? My situation is following: I have a input form with many fields, each of them has a onchange event registered. there is also a button to open a popup for some other/special things to do in there. My requirement is, that the onchange event(s) are finished before I can open the...

Is String.stipTags() enough to mitigate XSS attacks?

I am creating this UTF-8 encoded HTML page where the user can provide input. I wanted to make this XSS proof. I came across this free Javascript framework called Prototype which provides some useful functions. One particular function stripTags essentially strips all tags from the input string. Would the following input processing prevent...

Why doesn't Eclipse code assist on certain items?

a="hello"; b=a.sub(); document.write(b); My eclipse won't code assist when I write this JavaScript code. it's the sub() part. When I enter b=a.s and I press ctrl+space, it brings nothing. Why is that? ...

image gallery loop JS

var thumbs = document.getElementsByTagName("img"); for (var i=0; i<thumbs.length; i++) { Core.addEventListener(thumbs[i], "click", function() {alert(i);}); } In the above code, the alert always shows18. that is the number of image thumbnails. i want it to show which thumbnail i clicked. why isnt it showing that? also i need to p...

How can I make the window scroll by using mouse position?

Hi, If I want to use the mouse to scroll the window when it gets close to one of the edges how can I approach this? So far I have it working fine, it checks the position whenever it moves to see if it is close enough to the edge to scroll. However, it only checks the position whenever the mouse moves, so if you moved close the edge, i...

Refer to Root of Web Site in JScript

To refer to the root of a website in asp I use an ASP control (normal hyperlinks don't work!) and use the tide ~ However I am trying to achive the same with Jscript and it does not work. I have set up a folder structure to better organise the files on my website. I have placed a Jscript file within the root of the folder structure an...

How to find out when all addresses have been geocoded

In the Google Maps API, multiple calls to google.maps.ClientGeocoder.getLatLng(address, callback) are not guaranteed to finish in any order. What is an elegant way to determine all addresses have been geocoded, given an array of addresses? Should I just count down based on the length of the array and execute code in the callback only i...

Rich text user input in Rails

What's the preferred way to handle rich text user input in rails? Markdown looks useful, but I haven't found an editor that looks simple to setup for it, nor am I sure how to handle sanitizing the html. (the sanitize helper still seems to allow stuff like </div>, which breaks my layout) I'd like to guarantee that the cleaned up code is v...

Javascript and Actionscript 3 [Setting a variable woes]

Okay, so I'm trying to set a variable via a javascript method call. However this is not working. I googled and ended ip going back and trying swLiveConnect, but that's outdated and it turns out my way is now the way to do it. So here's my javascript function and actionscript. I have no idea what's going on, I bow before the more skilled ...

Saving a child window saves the parent window instead (Javascript)

Hello All, I have a bit of Javascript code that creates a "save friendly" version of a webpage. child = window.open("","child"); child.document.write(htmlPage); "htmlPage" is the basic html of the page with all the javascript references taken out, a different set of header images references, etc. Everything displays perfect...

How do you test that a modal jquery dialog has lost focus?

I want to close the dialog box when you click outside of the dialog, but I'm not sure how you test that in jquery/plain javascript. Some have suggested using the blur event, but this doesn't seem to be supported by jquery dialog. ...

ExternalInterface.call causing error in IE

Hi, I have a menu screen that for various reasons consists of a number of buttons as separate flash movies. When a button inside these movies is clicked, it is supposed to call a javascript function to move to the appropriate page. It works fine in firefox, but is currently failing in IE7. I don't have an IE6 handy to test on. This is th...

tinymce opening a new window switches to download dialog in firefox and chrome

Hello all, this pretty much is the thing. When in tinymce I press anything that is supposed to open a new window, such as color picker or a link dialog, FireFox/Chrome seems to start opening the window and then all of the sudden it opens a standard file download dialog asking if I am sure I want to download the requested html file. Sa...

How do you stop an infinite loop in Javascript?

Let's say I accidentally wrote this: do { } while (true); ...and then ran it. Apart from killing your browser, is there a way to stop javascript execution (the equivalent of Ctrl+Break in basic, or Ctrl+C)? Normally, after about 30 seconds your browser asks if you want to stop the long-running script, but this doesn't always happen ...

Google Analytics - Blocks HTML/page rendering

I have used the "Better Google Analytics JavaScript that doesn’t block page downloading" to load Google Analytics dynamically so that it will not block HTML / page rendering. However, it appears occassionaly that my HTML page will block rendering on the Firefox 3.0 (WinXP) status message states: "Transferring data from www.google-analy...

How do I create a "sound on/ sound off" button?

I've seen many web pages with a simple sound on /sound off button which plays music or some mp3 file when you press sound on and turns it off when you press off. How do I do that? Hi, I wasn't planning on using Flash -- if there is a standard plugin I could use and then make modification to the script, that'd be cool. I'm open to what...

How to dynamically load Javascript files and use them right away ?

I am using JQuery to inject dynamically script tags in the body tab of a webpage. I got something like : function addJS(url) { $("body").append('<script type="text/javascript" src='+url+'></script>'); } I add several scripts this way, and try to use them right after. E.G : lib.js function core() {...} alert("I'am here !"); in...