National Day is coming, mobile phone station (http://www.sjjyz.com) home page also want to bring visitors a little joy feeling, so art made two flash respectively on both sides of the web page blank place, at the same time, they want to scroll along with the page and feel floating.
When implementing the rolling effect, I began to use the JS event body onscroll as usual. However, when the flash was rolled, the two Flash files felt a little choppy. Like cramps, they made people feel bad. I tried to use CSS expressions to achieve the effect and found that the result was much better, the feeling of cramps is gone at all.
CodeAs follows:
<Style>
# Flashright {} {Position:Absolute;Top:Expression (locktop ());Left:Expression (lockleft (false )); }
# Flashleft {} {Position:Absolute;Top:Expression (locktop ());Left:Expression (lockleft (true )); }
</Style>
< Script Language = " Javascript " >
Function Locktop ()
{
VaR_ Body=Document. Body;
Return_ Body. scrolltop;
}
Function Lockleft (left)
{
If (Left)
{
Return(Screen. availwidth- 777)/2 - 134;
}
Else
{
Return(Screen. availwidth- 777)/2 + 770;
}
}
</ Script >
The Code becomes very simple.
< Div ID = "Flashright" >
</ Div >
< Div ID = "Flashleft" >
</ Div >
The specific effect can go to the http://www.sjjyz.com to see, these two days will take this change.