a question dhtml/javascript stuff
#1
Posted 09 June 2006 - 02:51 PM
Remember Emu's face, people; one day it's going to be on the news alongside a headline about blowing some landmark to smithereens, and then we can all sigh and say, "She was such a normal person".....
....We'd be lying though.
-Laughlyn
If my doctor tells me to exercise, I am going to force him to do my homework.
-Mirithorn
- Do Not Use the Elevators - deviantART - Infinite Monkeys -
#2
Posted 09 June 2006 - 03:18 PM
Quote
#3
Posted 09 June 2006 - 03:31 PM
(it also might be my grasp of coherency (rather, lack thereof) that failed you there...) I thought the other layers would be encapsulated within the one for which I made the scrolling overflow property, but apparently they are not. the structure's something like this:
<img id="im">
<img id="fg">
<div id="bg">
</div>
</div>
and the canvas is the one whose overflow property is being set to auto (scrollbars). the im is contained within the scrollbars as it should be, but the fg and bg "float" - they stay in place on the screen while the im is scrolling.
This post has been edited by Emu: 09 June 2006 - 03:32 PM
Remember Emu's face, people; one day it's going to be on the news alongside a headline about blowing some landmark to smithereens, and then we can all sigh and say, "She was such a normal person".....
....We'd be lying though.
-Laughlyn
If my doctor tells me to exercise, I am going to force him to do my homework.
-Mirithorn
- Do Not Use the Elevators - deviantART - Infinite Monkeys -
#4
Posted 09 June 2006 - 03:43 PM
Quote
#5
Posted 12 June 2006 - 10:15 AM
Remember Emu's face, people; one day it's going to be on the news alongside a headline about blowing some landmark to smithereens, and then we can all sigh and say, "She was such a normal person".....
....We'd be lying though.
-Laughlyn
If my doctor tells me to exercise, I am going to force him to do my homework.
-Mirithorn
- Do Not Use the Elevators - deviantART - Infinite Monkeys -
#6
Posted 12 June 2006 - 10:59 AM
#canvas { position:absolute;top:0px;left:0px;width:100px;height:100px;overflow:auto; }
#fg { position:absolute;top:0px;left:0px;visibility:visible; }
</style>
<div id="canvas">
<img id="im">
<img id="fg">
<div id="bg">
</div>
</div>
This version worked for me, so far. Don't know about the div-element yet, though, but most of the time it's the position-attribute's fault, so you may find a solution if you experiment with that one.
Quote
#7
Posted 13 June 2006 - 04:45 PM
Remember Emu's face, people; one day it's going to be on the news alongside a headline about blowing some landmark to smithereens, and then we can all sigh and say, "She was such a normal person".....
....We'd be lying though.
-Laughlyn
If my doctor tells me to exercise, I am going to force him to do my homework.
-Mirithorn
- Do Not Use the Elevators - deviantART - Infinite Monkeys -
#9
Posted 14 June 2006 - 03:02 PM
next question: say you have a div whose overflow=auto. how can you give it coordinates to tell it where to scroll to? I know that for the window element you can use window.scrollTo(x,y) but it won't work for DIVs. is there any similar thing like this for divs?
Remember Emu's face, people; one day it's going to be on the news alongside a headline about blowing some landmark to smithereens, and then we can all sigh and say, "She was such a normal person".....
....We'd be lying though.
-Laughlyn
If my doctor tells me to exercise, I am going to force him to do my homework.
-Mirithorn
- Do Not Use the Elevators - deviantART - Infinite Monkeys -
#10
Posted 14 June 2006 - 04:16 PM
Divs don't have .scrollTo, but something similiar, if I remember it right: .scrollTop
That would be a method of document, I guess. Try experimenting around with document.getElementById("IdOfYourDiv").scrollTop = someIntegerValueOfYourChoice; and see if it does something.
Sorry that this is so vague, but maybe it'll work.
Edit: Hmm... strange... I'm not so sure whether .scrollTop really is a method... but I think I remember it to be writeable, so it should work anyways. Oh, and that one's of course only responsible for y-coordinates. .scrollLeft should be the right method/attribute/whatever for x-coordinates.
This post has been edited by Gobbler: 14 June 2006 - 04:23 PM
Quote
#11
Posted 10 July 2006 - 05:15 PM
the page works in Firefox and IE, but not in Safari. the problem appears to be that Safari thinks that an im.width and im.height are 0, when firefox et.al. think that these are the original dimensions of the image in question (as they should be). it may be that the image isn't fully loaded when it's being asked its width and height? any other ways to get the original dimensions of a jpeg file?
Remember Emu's face, people; one day it's going to be on the news alongside a headline about blowing some landmark to smithereens, and then we can all sigh and say, "She was such a normal person".....
....We'd be lying though.
-Laughlyn
If my doctor tells me to exercise, I am going to force him to do my homework.
-Mirithorn
- Do Not Use the Elevators - deviantART - Infinite Monkeys -
#12
Posted 11 July 2006 - 01:03 AM
Quote
#13
Posted 12 July 2006 - 09:45 AM
a random image is being loaded to a canvas, I'm not sure of the details of how this is done, I think it might involve a CGI file or somesuch. the 'img onload' is a function called setImageDimensions(), which scales the picture to fit nicely in whatever size the browser happens to be. setImageDimensions uses in its calculations im.width and im.height (im being the image in question) - these are the original dimensions of the image, which are usually (but not always) something like 1600x1200. Other browsers handle this correctly - im.width = 1600 as it should be. but safari does not - it thinks im.width is zero. this is baffling because the image should have already loaded - since 'onload' is what happens after the image has loaded - so it should know the proper dimensions by then.
if I hard-code im.width=1600 and im.height=1200 in setImageDimensions, then the image displays just fine, the problem is I can't legitimately use that method to fix the problem because not all of the images have those dimensions. the problem is that the progrm should be able to get the dimensions of the image by itself, and not think it's 0x0. this problem is only happening in safari. so I need some safari-compatible way of obtaining the original dimensions of the image.
Remember Emu's face, people; one day it's going to be on the news alongside a headline about blowing some landmark to smithereens, and then we can all sigh and say, "She was such a normal person".....
....We'd be lying though.
-Laughlyn
If my doctor tells me to exercise, I am going to force him to do my homework.
-Mirithorn
- Do Not Use the Elevators - deviantART - Infinite Monkeys -
#14
Posted 12 July 2006 - 10:38 AM
var x, obj;
if (document.layers) {
var img = getImage(someImage);
return img.width;
} else {
return getElementWidth(someImage);
}
return -1;
}
I guess it's already a little bit obsolete, what with the deprecated document.layers and all, but well, it's the best I can come up with for now, sorry.
Quote
#15
Posted 12 July 2006 - 11:56 AM
thanks!!!
Remember Emu's face, people; one day it's going to be on the news alongside a headline about blowing some landmark to smithereens, and then we can all sigh and say, "She was such a normal person".....
....We'd be lying though.
-Laughlyn
If my doctor tells me to exercise, I am going to force him to do my homework.
-Mirithorn
- Do Not Use the Elevators - deviantART - Infinite Monkeys -