javascript

What's the approach to add javascript to a Tapestry application?

I'm starting with an existing webapp built with Tapestry. I can't figure out where to put the Javascript I need. Basically this application has a single page capturing data into a text area, and I want to include a javascript library to do something with that text area. What's the approach to add javascript to a Tapestry app? Any s...

CSS full page background scaling issues

How can I make a full page background image and not have it stretched (something like this)? <html> <style> html, body {height:100%;} #background { min-height:100%; min-width:1024px; width:100%; height:auto; position:fixed; top:0; left:0; z-index:-1; } @media screen and (max-width: 1...

JavaScript file upload is spotty

Hey guys, I have some code that uses the HTML input file type to upload XSL to a server-side program. While it works most of the time, once in a while the submit button will return with "The connection was reset," and my server will not have gotten anything (nothing was posted). Here's the code for the file upload, it's pretty standard:...

Tracing the source line of an error in a Javascript eval

I'm building something that includes javascripts on the fly asynchronously, which works, but I'm looking to improve upon the error detection (so all the errors don't just appear to come from some line near the AJAX call that pulls them down. If I'm using eval to evaluate a multiline javascript file, is there any way to trace which line ...

JavaScript class - Call method when object initialized

I have a class similar to the one below. How do I call my init method when the object is created? I don't want to have to create an instance of my object then call initialize like I do below. var myObj = new myClass(2, true); myObj.init(); function myClass(v1, v2) { // public vars this.var1 = v1; // private vars var2...

jQuery Gallery - Webkit problems.

Okay. So I've got a a little jQuery gallery scroller I wrote to work with WordPress. It works beautifully in Firefox, but it doesn't work in Chrome or Safari. Here's the link: http://thehousinggroup.info/our-gallery/bathroom-renovations/gallery-1/ Here's the jQuery: var imageQuantity = $('.galleryBox img').size() //finds the nu...

jQuery hashing and loading file, string formating?

Hey. I'm loading content dynamically like this: $("#id a").click(function(e){ e.preventDefault(); var hash = this.parentNode.hash; $("#show").load('files/'+ hash +'.html'); $("#show").fadeIn(300); }); But the hash is #first, #second, #third so I have to name files #first.html, #second.html etc. Ho...

Prevent any form of page refresh using jQuery/Javascript

Once the user is on my page, I do not want him to refresh the page. 1) Anytime, the user hits F5/refresh button on top. He should get an alert saying "You cannot refresh the page". 2) Also if the user opens a new tab and tries to access the same url in prev tab he should get an alert "You cannot open same page in 2 tabs" Anyway I ca...

Parsing string variable with jstl

Here's my problem. I need to set up a process, preferably with jstl/jsp, that depending on what a client enters in a URL parameter, a certain URL will be returned, with the same parameters passed on, and opened via javascript pop up function. Problem I am having, is that the choose statement is not finding one of the parameters unless ...

Change value of display:none input?

Is it possible to change the value of an <input type="text"> that has been hidden with a style of display:none? I have some JS that seems to work when the input is <input type="hidden"> but not when it's hidden with display:none. And AFAIK, you can't change an input's type with JS either. Basically, I want to replace an <input> with a <...

How to convert byte string into Number?

Hi all, I have a string encoded in Little Endian format (least-significant-byte first), and I want to decode it into a Number. For the encoder, the first bit of the last byte reflects whether the number is positive or negitive. Does anyone know how to do this? Here's my decoder: decode:function(str,type){ var num=0; va...

Inserting tags (WYSIWYG JavaScript editor)

I'm currently working on a WYSIWYG editor for a client (It's not like any other editor, it will also be able to insert drawings using HTML5) And I've been looking at and using several ways to insert content. Ok, so I have a div with contentEditable set to "true", and I'm stuck on a way make the text a different size/font by inserting ta...

jscript+wsh can't launch notepad.exe, vbscript+wsh can. Why?

Never mind, I solved it. It should just be <a href="#" onclick="runnp()">Run notepad.exe</a> Original question: I'm trying to write a webpage that will launch programs on my local computer. How come only the vbscript version works? Nothing happens when I click the jscript link. <html> <head> <script language="VBScript"> Sub ...

Clearing a value in javascript

I thought this was the syntax to clear out the value but its still present document.getElementById("themapdirectionsaddress").value = ''; I am trying to hide the text below the map, i know the element is a class but i changed it locally to an id to test and still nothing From I-4 take exit 104 Sanford/17-92. Head south on 17-92, note...

Change all links on a page to point to login with Spring MVC

This is more of a discussion, rather than a real question... I'm building a site and I am struggling with how to force a user to login to the site to access certain areas and take certain actions. I'm using spring security and have it integrated fairly well, however, I also have some AJAX calls that need to be secured and when Spring Se...

Can I determine what event triggered an event handler in jQuery if I bind multiple ones?

Check this example... $('button').bind('click focus', function() { // Did I click or focus? }); Is there a way to work that out when binding multiple events to one handler? This may work, but it is kind of ugly... var eventType; $('button').click(function() { eventType = 'click'; do(); }); $('button').focus(function() { ...

Disable multi select?

Is there a way to disable multi select? ...

If variable is null set the value to 0 with jQuery?

Hi, I am validating some fields and check if the length of a select element is larger than 0. I get the error "'length' is null or not an object" because id$=SelectResult is a listbox and can have no values and therefor return null and var val = $(this).val(); doesn't like that. function checkControls() { var itemLevel = $("select[t...

Google Search AJAX API, Retrieving Pictures and storing them into destinated path on handphones?

When users search for etc, Sir Stamford, there'll be pictures of him returned on the Google search list of pictures and i'll want to store the first image returned from the search onto the mobile device, namely Samsung Omnia. I currently have a search which returns the pictures of requested query and would like to store them somewhere s...

JavaScript gets rid of trailing slash in <img /> tag

I have the following JS code: validateConfigName.html('<img src="/rta/images/check-24.png" />'); But when it executes in Firefox I see this as the generated code: <img src="/rta/images/check-24.png"> Why? ...