Thursday, August 4, 2011

Jquery hide and show function cause weird behavior in flash movie

I encountered some weird problems for my flash control when I used Jquery function hide() and show() on it. I did some research and found other people had other weird problems too. For example, some saw their flash control reload and go back into the initial settings after show() function. I found a very good solution to my case, instead of using Jquery to hide and show, I simply hide the div where flash is in by setting its bottom to large negative number. Here is my codes:


function ShowInd() {
            $('#divInd').css("bottom", "0px")
}

 function HideInd() {
            $('#divInd').css("bottom", "-4000px")
}

For this to work correctly, I also set the "overflow" to "none".
Since I am on the hide/show element topic, I also want to clarify the difference between display: none and visibility: hidden for hiding an element.



visibility: hidden hides the element, but it still takes up space in the layout.
display: none removes the element completely from the document. It does not take up any space, even though the HTML for it is still in the source code.


Example from about.com: http://webdesign.about.com/od/examples/l/blfaqhidden.htm

Happy coding!