PDA

View Full Version : Floating Top Bar Keep Last Position Help



Worshipman
02-20-2006, 03:47 PM
Floating Top Bar
http://www.dynamicdrive.com/dynamicindex17/floatbar.htm

Link to the page I am working on
http://worshipfilms.mine.nu:8008/collections.php?coll_id=18

I setup the floating top bar on my site to display flash videos dynamically when a user clicks on the video link. Currently the only video I have encoded into flash is Scene #002 - Chase. So if you click on the image of the second video you can see the script work. Unfortunately my test server is on a cable connection so streaming video is kind of choppy but you can still see it work.

I added a function openbar() to the script so I can call closebar() on the page load and then have the bar open when a user clicks on a link. Everything works great except when you scroll down on the page and click a video link then openbar() is called and the page jumps to the top and opens the video.

Here is the openbar() function.

function openbar(){
document.getElementById("topbar").style.visibility="visible"
}

I tried setting
startY = (document.all)?iecompattest().scrollTop:window.pageYOffset + 5;
at the beginning of the staticbar() function and it causes the window to open in the correct place but then it scrolls to the top which is what I want it not to do.

If anyone can help me I will give you the swf file that I created to stream external flash encoded video (.flv) and a copy of the script that sends the variables to the swf.

Also if you're interested my live site is http://www.worshipfilms.com

jscheuer1
02-21-2006, 11:13 AM
The reason the page is jumping to the top is not because something is being made visible, that should never cause a page to change its scroll position. The reason is the link itself for 'Close' on the video pop-up:

http://worshipfilms.mine.nu:8008/collections.php?coll_id=18#

When the last thing on the address is '#' it means to jump to the top of the page. I have a feeling (though I couldn't easily locate it in the code) that what that link's href actually is in the code is:

href="#"

If I am right about that, simply change it to:

href="javascript:void(0);"

and it should be fine. You may also want to get rid of some of that added code you mention in your post as it wasn't helping and didn't address the real problem.

One other thing, if the link is something like so:


<a href="#" onclick="closeVid();">Close</a>

You can also fix it by adding:


<a href="#" onclick="closeVid();return false;">Close</a>

Worshipman
03-10-2006, 09:09 PM
Thanks for the info. I had already fixed it by adding the id of the div after the # but then every time I clicked on a different video the page would jump about 5 pixels down which is the amount of the y offset in the original floating top bar code. I was going to live with it but putting javascript:void(0); for the href works perfectly.

As promised you can download my source files including the fla here (http://www.worshipfilms.com/flashvideo.zip).

Please note that I started out with the flash video tutorial and added the external interface class to it so you will see some code in the fla written by Macromedia.