javascript

How to set header information

I have a piece of Java code which tries to access the header information posted by an html page.Right now I don't have the html page but I need to access the header information in the java file details.Can anyone please help me in writing a html page which sets header information? ...

Get button's width attribute value with jQuery in IE

Having this button on my page: <input type="button" id="Button1" value="OK" class="buttonClass" width="150px"/> and using jQuery 1.3.2, if I run this command: alert($('.buttonClass').attr('width')); I get '150px' in all browsers but in IE (any version) I get '0'. if I add a custon attribute in the button's tag, something like this...

Onload-script not working in Firefox

I'm writing a customer form, where a drop down menu should be automatically set to the appropriate option if the window.top.document.url is known. To achieve this I do a <body onload='javascript:init([Generic value])' which calls function init(value) { if (value) { document.getElementById('RefererURL').value = window.to...

How to get Google Maps API to set the correct zoom level for a country?

Is there a was of automatically setting the zoom level based on the size of the country that the map has been centered on? maps.google.com does exactly what I need, so, for example, if I search for Russia I get a zoom level such that Russia just fits on screen, and when I search for Cuba I get a higher zoom level so that Cuba just fits....

Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?

Given a simple zero based, numerically indexed array: var list = ['Foo', 'Bar', 'Baz']; Many times, I have noticed that when someone suggests looping through variables in an array like this: for(var item in list) { ... } ...there's almost certainly someone suggesting that that's bad practice and suggests an alternative approach: v...

jquery: get mouse click if inside a div or not

Hello i have this HTML page <html> <body> <div>a</div> <div>b</div> <div>c</div> <div>d</div> <div id='in_or_out'>e</div> <div>f</div> </body> </html> a,b,c,d,e and f could be divs also not just a plain text. I want to get the mouse click event, but how could i know if it's inside or outside #in_or_out div ? EDIT :: guys, i know h...

jquery : dynamic events how to achieve

Hello. What is the best way to do this dynamic events linking between divs in jquery. my HTML page: <html> <body> <div id="parent1"></div> <div id="parent2"></div> <div id="parent3"></div> <div id="child1"></div> <div id="child2"></div> <div id="child3"></div> </body> </html> for each clicked parent i want to .toggle its child ...

Cant find the problem, IE appearance problem

Hello. I have this ajax_update script that updates file.php every 60 seconds.. Now file.php outputs this after updated a table: <div id="message" style="display: none;" onclick="closeNotice()">this works </div> What I am trying to do is that after file.php have updated a field in the database(points), there will come up a message like...

What strategy should I use for multiple room booking selection without JS?

The user requests 2 rooms on the initial page and is then presented with room types to select from on step 2. The arriving and starting dates will always be the same, but the number of adults and children may differ, causing the price to fluctuate. Now, if JS is enabled I think I'll just program it such that it's tab-powered and when yo...

How to access js object properties via html element?

Hi, I have an array of objects fetched using jQuery.getJSON(). I want every one of my objects to be represented by HTML div element, so when you click the element you have access to all the properties of corresponding object. What is the best way to do it? I wanted to do it like this: $('.mydiv').click(function() { var id = $(this)....

jquery add li to end of ul but last created li not recognised as last

I have the following code. On cliking the button on the last li, I can create the new li. However, once created, if I click on the latest button created, new li is created. It seems it doesn`t recognise the last created li as the last li. Can someone help on this please. <html xmlns="http://www.w3.org/1999/xhtml" > <script...

JavaScript removes slash from JSP variable

Have JSP variable ${remoteFolder} It's value is \\file-srv\demo Use jQuery embedded in this JSP. jQuery resolves ${remoteFolder} variable as \file-srvdemo ,i.e. one slash is removed. How to remain initial value of this var? edited: when ${remoteFolder} is used inside form tag, that it resolved OK. edited2: JS part of JSP, slashes ...

Javascript function organization

I am not exactly sure the differences between saying "function x(){}" or "this.x=function(){}", but I had to make an object oriented JavaScript which is laid out like this: function PROJECT(){ ... ... ... this.main_call=function(...){ return this.recursive_call(...); } this.recursive_call=function(...){ ... var local,...

Can we count how many times an item has been shared in Google Reader?

This is related to recent "Google Buzz Count" feature on famous blog Mashable - http://mashable.com/2010/02/12/google-buzz-buttons-count/ While trying to dig into logic they are using for "Google Buzz Count", I somehow reached to the conclusion that, essentially, they are counting how many times an item has been shared in Google Reader?...

How to check if an object is not an array?

So i have a function that needs to check if an argument is an object, but this fails because: typeof [] // returns 'object' This is a classic javascript gotcha, but i cant remember what to do to actually accept objects, but not arrays. ...

ajax safety in javascript games

In my JavaScript game (made with jQuery) I have player position stored in a database. When character is moving, i just send request to specyfic URL, I.E. mysite.com/map/x1/y3 (where a character's position is x=1, y=3). That url send coordinates to the database and checks to see if any other players are near ours. If yes, it sends also...

edit and save image in google app engine

Hi, In my GAE Java, I would like the user to be able to edit the images that I serve, using Javascript, and then upload that image back into the GAE. The reason I am thinking of using Javascript is that GAE Java does not have many image editing capabilities. Original image is stored as Blob in DataStore. Image is served (currently) j...

jQuery Ajax HTTP Request INTO a click function - not working

Hello everyone! My question is: Is it possible to do an Ajax request WITHIN a click function, with jQuery? (see example below), If so, what am I doing wrong? Because I'm not being able to do any request (I'm alerting the data through my success function and nothing is being retrieved). Thank you very much in advance for any help! :) ...

How to set drop down list option up to specific value

If I have valvo that obtain from database, How can I set volvo option status into active(checked) by using JQuery? <select name="car"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </select> I don't know how ...

How to increase google searching limit?

I have built an Plagiarism Detection application, using Google API and JavaScript which is working fine, but It could not search when searching material exceeds more than 235 words. Please tell me how to do that. ...