Alert shows the distance from input to the top of the table or table cell.
Is there any other attribute which shows the absolute distance from input to
the top of the page ? Because of some reasons I can't add table's and
input's offsetTops.
I have a page which contains an <ul> list with 5 items. Each of those items has a data-weight attribute which corresponds to its importance in the list. I have to make only one random list item appear and use the weight to make sure that the most important one shows up more often than the least important item.
I am currently getting the position of a DOM element by using offsetLeft & offsetTop. This works fine, but I notice that when I use these properties in Internet Explorer the values returned are slightly different from when I use them with Firefox, Safari, or Camino.
I am basically trying to create a DIV over a certain part of a fixed table, so I use offsetLeft & offsetTop to get the coordinates of that table and then position my DIV based on those coordinates. The problem is that with Internet Explorer it seems to be a few pixels off compared to when I do it with Firefox, Safari, or Camino.
I've used Brian Crays driving distance calculator on a site, however the calculations are not accurate for full addresses. I realise the v2 google maps api is now depreciated, my question is, if I upgrade to v3, is there more accurate calculations of distance and if so, does anyone have an example of calculating the distance between two points with the new api?
or does anyone know how to get more accurate results with his code?
What i'd like is a simple converter to allow a user to input the distance travelled in miles and the time in hours and minutes, the result being an average speed. What i'd appreciate is for someone to write the script for me and post here if possible.
i've found out how to find the distance between 2 lat lng points using google's distanceFrom method:
Code: // NR14 7PZ var loc1 = new GLatLng(52.5773139, 1.3712427); // NR32 1TB var loc2 = new GLatLng(52.4788314, 1.7577444); alert(loc2.distanceFrom(loc1) / 1000);
However, I'd like to be able to convert a distance to lat lng. The main reason I'm doing this is so that I can figure out the bounds of a certain area of a co-ordinate. For example I specify a point, and then I need to draw a box around this area going x distance North, South, East and West, but until I know how many units make up a kilometre this wont be easy.
I guess I could go to google maps, click on a point and then click on another point and keep doing that until I get exactly 1km away from the original point, then just minus or plus for the lat and lng to find out the unit value for 1km, but I have a feeling that this wont be accurate. Can anyone lend any advice, I realize that what I'm asking is more a map question than a google maps javascript api question, but perhaps someone has come across this before?
I've got this lovely little animation that slides some div fields to the right a short distance. Everything works except the setTimeout (located in the SlideIn function). It simply 'jumps' without taking any time at all. I've tried a bunch of stuff:
changed the amount of time from 100 to 10000 changed it from var t = setTimeout("SlideIn()", 1000) SlideIn with/without the brackets, with/without the quotation marks.
I am doing some work, where I want to have a table heading that remains in a fixed position, when the window is scrolled (I will ultimately have a very long table). I have written the code below, which fixes the heading.
I am trying to make it so that each body row of the table gets hidden, when the window is scrolled such that the row passes above the heading row.
To do this I need to somehow detect the distance of each row from the top of the window as the window is scrolled so I can detect when it goes above the fixed heading row. I have tried to do this using offsetTop and scrollTop in the code below, but it doesn't seem to be working (in Safari at least, which I am using for my main testing).
Does anyone know a simple way of detecting the distance to the top of the window so I can use it in my code below, which will work in all browsers?
(I don't really want to use div, and overflow-y:auto to achieve the fixed heading scrollable table, because I don't want to have a sub-section with its own scrollbar. I just want to have the main page scrollbar when the list gets long enough to require it.)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head>
I've found the Harvesine forumla to get the distance between any two points of latitude and longitude on the earth's surface. What I want is a little different - I want that, given a point and a distance, to get the latitude and longitude of a second point. I'm having trouble reversing the forumla. The current formula:
In all the easing functions (based on Robert Penner), I see that they require the distance to travel to be known beforehand. But what if I didn't know that? How would I calculate the change to position based on easing my speed to zero if I know my current speed?
In other words, I know my start position, my current speed and the duration. I want to figure out the change in position (for each step and total change).
I'm currently doing on a project, frankly speaking i'm new in javascript only know the basics. I'm not even sure whether this thread is suppose to be here or under html.. I'm suppose to create some codes that enable a html page to load to the next html page when the mouse move from left to right within a specific time and distance(positive X coordinate) and also the other way round (right to left) once i figured out this. I've got an example online and edited it. Please take a look at my codes.
[Code]...
test01.html is just blank page created to make sure it loads. However i would like to load from test01 to another html page but no matter how i tried to edit the codes, there's errors. I cant possibly copying and pasting the exact codes to every page i want to load to right? And is it possible to sortof increase mouse sentivity such that i can most probably load to the next page in first few tries of moving the mouse on the first page. Is it common that when i launch the html on IE and Firefox somehow after showing the first page for maybe 1 second, it immediately jumped to 2nd page and i have to go back to 1st page to try out.
i have found a possible bug in 1.4 but it's only in Internet Explorer 7 & 8.The following code does not work and completely ruins every peice of jquery on the page (that means everything inside $(document).ready and anyting else...
I cant see any syntax errors - i pulled the example from the 1.4 site. There is no trailing commas in the object notation and i really cant see any reason it would work in firefox and not IEx and more to the point not only not work in IEx but break any other jquery in the entire page....
I'm working with a large (and unweildy) ASP.NET application, and there is a lot of jQuery code that uses selectors like this:
[name=_aspnetControl$_withASubControl] And unfortunately, some selectors that also look like this:
[name^=_someAspNetControl$_radioButtonList].
In other words, the effort to remove the $ from the attribute selectors would be monumental. If it is possible to escape the $ symbols, I can do that easily enough, but unfortunately the situation right now means that I can't upgrade to jQuery 1.5.
I'm learning jQuery with XML. I'm familiar with other query languages such as XPath. I'm having a little bit of difficulty wrapping my brain around how jQuery works but I think I can make the leap if I see a solution to a problem I know how to solve with other methods Given the following XML, please share a jQuery solution to finding the value of attribute B in elements named bar where attribute A has the value 30:
I'll trying to tell the difference between the following three cases:
<img alt="text string" /> <img alt="" /> <img />
I can do this in Firefox with the following code, where elem is the HTMLElement representing each image, but IE doesn't seem to differentiate between empty string and undefined.
var alt = elem.getAttribute('alt'); alt = (alt) ? alt : ((alt===null) ? 'really_null' : "");
The desired output from running this code on the 3 tags above is:
text string
really_null
It seems like this should be really easy...but I'm having a really difficult time trying to figure out what's going on...
Before you immediately give me an answer, let me describe fully what I'm trying to do, as it's not as simple as the title suggests.
I need to get the absolute position of a DIV (top and left properties) relative to the viewport/screen.
I've tried using .offsetTop and .offsetLeft, but these return the top and left properties relative to the DIV's immediate parent element, not the viewport (unless of course the DIV is top-level and not contained in any other DIVs).
So, is there any way to retrieve the absolute position of a DIV relative to the viewport, even if that DIV is nested in other DIVs?
How do I put "cont" div on the right of "leftmenu" without using "absolute"?? The screenshot was little bit cropped out and there is no problem on width.
Its said that placing the absolute div within a relative div is a best option to correctly achieve the margins within that relative div. However, I'm changing the marginTop and marginLeft via javascript and after some of the changes it shows the absolute divs in incorrect positions in IE.
What i want to do is calculate the vertical-middle right-sided position of text fields in x, y meaning in top and left margins. How can I do that?
This works fine in IE: the div is positioned relative to the td of menu1. However, in Mozilla it doesn't work. The div becomes relative to the top of the page.
I'm having some trouble with absolute positioning:
I have a main div, with some nested divs inside, one of which is "position:absolute". When a user hits a button, a message will appear at the top of the div (by using "myDiv.style.visibility = 'block'"), which pushes all other sections, relative or absolute, down appropriately. This is what i want.
However when the message div is clear (using "myDiv.style.visibility = 'none'"), all the relative divs go back to their original position, but the absolute div stays at its pushed down position.
ive tried several complicated schemes to correct this, including setting the absolute sections top to certain values, and it doesn't want to move back.
Does anyone know a solution to this problem, or of a way to "refresh" a divs position?
I got a script from brothercake which gets the absolute position for an element. Its pretty neat - recursively adding up offsets. I got it from the image transition scripts on his site.
However, this script uses offsetTop, offsetLeft and offsetParent, which dont seem to be supported by FireFox (or maybe I'm doing something wrong).
It seems to work for Opera and IE - but not FF. Cant say for other browsers. I've come to rely on it for a part of my 'cross-browser' page. Any thoughts on what I can do?
What I can't figure out is why it seems to work fine on brothercake's site - even in FireFox. I'm supposing that the positioning script must be working because the images appear in the right spot.