javascript

Best practice javascript and multilanguage

Hi folks, what is the best practice for multilanguage website using DOM Manipulating with javascript? I build some dynamic parts of the website using javascript. My first thought was using an array with the text strings and the language code as index. Is this a good idea? ...

Class methods as event handlers in javascript?

Hi, Is there a best-practice or common way in Javascript to have class members as event handlers? Consider the following simple example: <head> <script language="javascript" type="text/javascript"> ClickCounter = function(buttonId) { this._clickCount = 0; document.getElementById(buttonId).onclick =...

Using JavaScript within a JSP tag

I've seen this question regading the importing of js-files related to the tag content itself. I have a similar problem, here I have a jsp tag that generates some HTML and has a generic js-implementation that handles the behavior of this HTML. Furthermore I need to write some initialization statements, so I can use it afterwards through J...

How can Print Preview be called from Javascript?

I have a page that is supposed to launch the Print Preview page onload. I found this: var OLECMDID = 7; /* OLECMDID values: * 6 - print * 7 - print preview * 1 - open window * 4 - Save As */ var PROMPT = 1; // 2 DONTPROMPTUSER var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A...

Javascript classes and DWR

I've been playing with DWR and converters for a while and I really wanted to map my Java classes to JavaScript classes. Using DWR converters, I have the option to point out what is the name of my JS constructor given a Java class. So far so good... The problem arises when my JS constructor is within a JS package-like name (just like YUI'...

Need an example explaining why use of comparision operands != and == is considered bad practice in JavaScript.

As I've read somewhere it is advised to use !== and === instead. ...

Using JavaScript with JSF and Facelets

I would like to use JavaScript to manipulate hidden input fields in a JSF/Facelets page. When the page loads, I need to set a hidden field to the color depth of the client. From my Facelet: <body onload="setColorDepth(document.getElementById(?????);"> <h:form> <h:inputHidden value="#{login.colorDepth}" id="colorDepth" /> </h:form> ...

AJAX, Subdomains, and SSL

I have a site, foo.com, that makes ajax requests to bar.foo.com. Will this work. Also, if foo is a secure connection, https, does bar.foo.com need to be https too? Can these two sites use different certificates? ...

Has anyone used or written an Ant task to compile (Rhino) JavaScript to Java bytecode?

I'd like to use the Rhino JavaScript compiler to compile some JavaScript to .class bytecode files for use in a project. It seems like this should already exist, since there are groovyc, netrexxc, and jythonc tasks for Groovy, NetREXX(!) and Jython, respectively. Has anyone used or written such an Ant task, or can anyone provide some tips...

Loop through <select> and build array in the format: "value1","value2","value3"...

I wonder if anyone could suggest the best way of looping through all the <option> s in a <select> element with jQuery, and building an array. Eg. Instead of the following, whereby a string ins passed to the autoCompleteArray(), $("#CityLocal").autocompleteArray( [ "Aberdeen", "Ada", "Adamsville", "Zoar" //and a million oth...

Get size of SVG graphics by javascript

To add a svg graphics in html page, it is common to use object tag to wrap it like this: <object id="svgid" data="mysvg.svg" type="image/svg+xml" wmode="transparent" width="100" height="100"> this browser is not able to show SVG: <a linkindex="3" href="http://getfirefox.com"&gt;http://getfirefox.com&lt;/a&gt; is free and does it! I...

How do you Manage Infragistics WebGrid Data from JavaScript/Ajax code?

I am working on a project that I need to use the Infragistics WebGrid control for some lists of data. I am loading the data on the client-side using JavaScript for display on a Map, and then I need to display that same data within multiple WebGrids. All the data available will be displayed in the WebGrids, but only a subset of the data (...

Expand and collapse issues.

Hello, I'm a rookie designer having a few troubles with this page: http://www.resolvegroup.co.nz/javasurvey.php There are problems with the javascript operation of the expanded questions. For Internet Explorer (Version 7) the first question when expanded gets partly hidden under question 2. This happens to varying degrees with all ques...

How to refactor from using window.open(...) to an unobtrusive modal dhtml window?

Hi, I have a function which launches a javascript window, like this function genericPop(strLink, strName, iWidth, iHeight) { var parameterList = "location=0,directories=0,status=0,menubar=0,resizable=no, scrollbars=no,toolbar=0,maximize=0,width=" + iWidth + ", height=" + iHeight; var new_window=""; ...

Can I trigger a complete web page reload with content from a javascript string ?

This is one of those ajax "alternate flow" questions. Normally I expect my ajax request to return a part of the page. But sometimes it may return a full page with html, head and body tag. At the time I return from my ajax-request I can detect if this is a full page, but is it possible to trigger a full page reload (with full event cycl...

Javascript World Timezone Difference to GMT Calculator

Dear everyone I was hoping someone could send me in the direction of a regularily updating time zone database. I have found one, but apologies i cant remember where it was from, however with the current GMT clock change fast approaching, i fear all my data will be incorrect, ie the differences from UK to New Yrok will change from 5 hou...

What is different with window and div widths between firefox and IE

I have a web page that uses a scrolling div to display table information. When the window is resized (and also on page load), the display is centered and the div's scrollbar positioned to the right of the page by setting its width. For some reason, the behaviour is different under firefox than IE. IE positions/sizes the div as expected, ...

Splash page in Wordpress

Hi, I'm starting a Wordpress Blog that will have adult content on it, so I'll need a first-time-only splash page in Wordpress. The first-time-only issue, I can fix with a cookie (although I am aware that not everyone has cookies enabled) What I could do is, create a script that loads another page if a cookie isn't present. Or I could ...

What's the best way to open new browser window?

I know that most links should be left up to the end-user to decide how to open, but we can't deny that there are times you almost 'have to' force into a new window (for example to maintain data in a form on the current page). What I'd like to know is what the consensus is on the 'best' way to open a link in a new browser window. I know...

How do I pre-populate a jQuery Datepicker textbox with today's date?

I have a very simply jQuery Datepicker calendar: $(document).ready(function(){ $("#date_pretty").datepicker({ }); }); and of course in the HTML... <input type="text" size="10" value="" id="date_pretty"/> Today's date is nicely highlighted for the user when they bring up the calendar, but how do I get jQuery to pre-populate...