javascript

HTMLDocument getElementById for a custom control returns null, why, and is there a different way to access it?

Hi guys, I have the following in an aspx page inside a body tag: <form id="Form1" method="post" runat="server"> <customControl:menu id="Menu1" runat="server"> </customControl:menu> </form> And from a different aspx page I have this javascript function: <script type="text/javascript"> function testFunction(args, name) { alert(to...

javascript: move image upon button click

I am looking for a simple script to move an image in JavaScript. Code examples from Google search results are not working for me. Please help. ...

Is there a means of executing code during the startup of Apache Tomcat 6.x to perform intialization routines, etc.?

I want to initialize a global instance of a class before my Tomcat server completes startup and begins to offer my servlets. If this service somehow fails initialization, I'd like the entire startup sequence to fail as well (or as close to this as possible; it would be pointless for the server to be running otherwise). What's the best ...

Call PHP page via jQuery/Ajax

Let's say I have a PHP page and inside that PHP page I just have <?php echo "Hello World!"; ?> and I want to use JavaScript (preferabbly jQuery) and AJAX to CALL that php page and return it's output (which would be "Hello World!") How is this done? ...

Javascript fade or crossfade background images

Hello! Is it possible to fade in / crossfade background images please? If so, how... Thank you. ...

Stopping the video if the rotate is moving

Ok so i have this page. As you can see on this page I have a header that if you click on the three little dots on the right a new image and movie is displayed. this works great at the moment. The problem is the client now wants the page to rotate and I have tried this in the past but the problem arises when someone clicks on the movie an...

Auto-scroll <textarea> with Javascript

I have this textarea that shows inputted text, but when the number of lines exceeds the size and width of the textarea, the user has to scroll down to see what they have last inputted. I'd like the textarea to be set to the bottom everytime the enter button is pressed. I've tried the following, but I can't get it to work: function inp...

Login and stay on the same page?

I'm trying to make a sleek login function here =) I want the "login experience" to be smooth and seamless, so I don't want the user to "feel" like he/she is being "redirected" and taken back to the same page again. So the process goes: User X visits page A X is not logged in X presses on Login btn (that lives in a in a div together w...

What's the best way to play a sound from my website?

I know it's generally frowned upon, but in this case I think it might actually be helpful. I want to play a little "ding" sound when a new item is posted on my site. I'll leave the option to turn it off of course. Now should I do this with JavaScript? Would jQuery be helpful? Or should I use Flash? Looking for something that is widely c...

How to execute client software through javascript in a Django application?

Im thinking about creating an asset management application in Django. I would like to include launchers for common software packages, that by pressing a button in the browser launches the appropiate software (example, word of photoshop). How would I go on about doing this? ...

JavaScript library for Time and Date Fields

Hey All, What's the best, free JavaScript library to work with time and date fields in a JSP project? Here are my needs: Formatting should be customizable. For a date field, a date picker popup would be a plus. Does not allow the user to enter invalid characters, much like the time field in Windows clock. Does not depend on jQuery. N...

Javascript - How do I declare a variable with the variable name based on a string?

var cur_storage_unit = $('#storage_unit').val(); $('.size_unit').change(function() { var id = $(this).attr('id'); //This is how I want it to work, but not sure how 'cur_' + id = $(this).val(); }); The user 'changes' a of class 'size_unit' and id of 'storage_unit'. I want to then set the value of 'cur_storage_unit' to the...

use querySelectorAll to retrieve direct children

I am able to do this: <div id = "myDiv"> <div class="foo" ></div> </div> myDiv = getElementById("myDiv"); myDiv.querySelectorAll("#myDiv > .foo"); That is, I can successfully retrieve all the direct children of the myDiv element that have class .foo. The problem is, it bothers me that I must include the #myDiv in the selector, bec...

Overriding Browser's Keyboard Shortcuts

I'd like to add support for keyboard shortcuts to a couple of pages in my web application by intercepting the keypress event handler of the document object, not the accesskey attribute. The problem is that every browser has its own keyboard combinations, so it's impossible to come up with a set of keyboard combinations that work on all ...

Photoshop - Open Save for web & Devices Dialogue using javascript.

I am trying to find out how to open Photoshops "Save for web & devices" dialogue box using javascript. I have automated everything else but could not find anything on how to open the dialogue via a JSX photoshop Javascript file. Any help would be appreciated. Thanks. ...

How to post form using jQuery?

I have a form with a submit button and it works fine, but I now have a user request to make the form get saved (posted to save action) if a link on the page is clicked and the form is "dirty". I've got the logic in place by having an isDirty JavaScript variable, now I would like to post the form from the JavaScript function when it is d...

Regular expression for matching incomplete tags in the form $tagname$

I have a small templating system in javascrip, where the user can put tags in the form $tagname$. I can match all tags with the patter: /\$\w+\$/. Also, I want to match incomplete tags specifically (it would start with $ and finish with a word boundary that is not $). I can't use /\$\w+\b/ because $ is also a word boundary (so it will a...

there is something wrong with this Jquery post?

im trying to pass on the id attribute to the file.php, but its giving me 0 every time, when i try to insert it into the database, the javascript and the html is provided! $(function() { $(".follow").click(function(){ var element = $(this); var I = element.attr("id"); var info = 'id=' + I; $.ajax({ ...

Confirm browser back button else stay on page

In javascript or jquery I need to add an alert when the user clicks on the browser back button that has an ok/cancel button model, but instead of "Ok" it should say Leave and instead of Cancel it should say Stay. Thanks ...

What's on your javascript code review checklist

I'm implementing a code review process, among the things to be reviewed is javascript. I've been asked to make a sort of checklist of things to look for when reviewing code. So far my checklist is as follows: no functions or variables in the global namespace. write efficient code, especially in loops don't append to the dom in a loop. ...