Forum Moderators: open

Message Too Old, No Replies

embed movie file issue - show/hide divs not working in Safari

works in browsers other than Safari

         

Drag_Racer

8:17 pm on Jul 7, 2007 (gmt 0)

10+ Year Member



Just built a page for a client and in the document there are two quicktime movies. One is just a smaller version of the other so I don't need to have both on the page at the same time.

The client wants just one page to serve both files along with a bunch of other stuff. so I need a solution to have both files in the document without both downloading.

My solution was to create div's for each and have javascript show the one the visitor asks for.

there is a script which swaps out the video on the page by clicking an image. Basically hides one div and clears it, then shows the other div and populates it

works fine in FF1.5, IE6, and OP8, but video will not work when changed in Safari

<script type="text/javascript">
function swapV(){
var v1=document.getElementById('vid1');
var v2=document.getElementById('vid2');
var i=document.getElementById('swp');
if(v1.style.display=='block'){
v1.style.display='none';
v1.innerHTML='';
v2.style.display='block';
v2.innerHTML="<object width='320' height='250' classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='http://www.apple.com/qtactivex/qtplugin.cab'><param name='src' value='pathtosmallfile.mov'><param name='autoplay' value='false'><param name='controller' value='true'><embed src='pathtosmallfile.mov' width='320' height='250' autoplay='false' controller='true' pluginspage='http://www.apple.com/quicktime/download/'></embed></object>";
i.src="videoswap_s.gif";
}
else{
v2.style.display='none';
v2.innerHTML='';
v1.style.display='block';
v1.innerHTML="<object width='720' height='490' classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='http://www.apple.com/qtactivex/qtplugin.cab'><param name='src' value='pathtofile.mov'><param name='autoplay' value='false'><param name='controller' value='true'><embed src='pathtofile.mov' width='720' height='490' autoplay='false' controller='true' pluginspage='http://www.apple.com/quicktime/download/'></embed></object>";
i.src="videoswap.gif";
}
}

the html is two div's, one for each video. both included in the page for accessability of course and to keep them both accessable to spiders, etc. then a script to clear one div so not to download bnoth files at the same time, then the image to click on to swap the vids
html below...

<div class="vid" id="vid1" style="display:block;"><object width="720" height="490" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="pathtofile.mov"><param name="autoplay" value="false"><param name="controller" value="true"><embed src="pathtofile.mov" width="720" height="490" autoplay="false" controller="true" pluginspage="http://www.apple.com/quicktime/download/"></embed></object></div>
<div class="vid" id="vid2" style="display:none;"><object width="320" height="250" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="pathtosmallfile.mov"><param name="autoplay" value="false"><param name="controller" value="true"><embed src="pathtosmallfile.mov" width="320" height="250" autoplay="false" controller="true" pluginspage="http://www.apple.com/quicktime/download/"></embed></object></div>
<script type="text/javascript">document.getElementById('vid2').innerHTML='';</script>
<a href="#top"><img id="swp" src="videoswap.gif" width=393 height=33 alt="click to change video size" title="click to change video size" onClick="swapV();"></a>

My first thought is Safari is having problems with the innerHTML, but I really don't want to write out the whole DOM then appendChild thing. I don't have a mac to test it and the client has an OS X machine and I need to make him happy ya know.

anyone have any experience with this type of error

tedster

8:02 pm on Jul 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There was no response in the HTML forum, so I'm moving the thread to the Javascript forum.

Drag_Racer

10:40 pm on Jul 26, 2007 (gmt 0)

10+ Year Member



I was not able to take the time to research this bug properly due to client needs. So, as a fix I removed the object and embed code from this document and replaced it with an iframe. The object and embed code was palced in a couple external html files. The source of the iframe was then used to load these external pages. To get the same effect as posted above, I dydnamically change the src of the iframe. For resizing the iframe, the width and height is set to 100% and dynamically changed the containing div element.

So, again I don't know for sure what the issue with Safari was. It just seemed to have a problem dynamically recreating the objects.

this new solution was also faster to render and more stable in Firefox., IE and Opera had similar results with both solutions.