2010-05-21 82 views

回答

1

我很惊讶没有JavaScript专家把这个。我的解决办法是在这里:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
    <title>PopUp Player using JWPlayer</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

    <style type="text/css"> 
     input 
     { 
     width:         300px; 
     height:         32px; 
     font:    bold 13px Verdana, serif; 
     text-align:        center; 
     color:         #fe0320; 
     background:   url(player.gif) repeat-x; // 1px wide, 32px high 
     cursor:         pointer; 
     border:          0; 
     } 

     img 
     { 
     position:        relative; 
     display:       inline-block; 
     float:          left; 
     border-width:         0; 
     margin:          0; 
     padding:          0; 
     font-size:         0; 
     cursor:         pointer; 
     z-index:          1; 
     } 

     div.clickmecontainer 
     { 
     cursor:         pointer; 
     } 

     div.clickme 
     { 
     position:        absolute; 
     display:       inline-block; 
     width:          79px; 
     top:          50%; 
     margin-top:        -15px; 
     text-align:        center; 
     color:         white; 
     font-family:       Journal; 
     font-size:        1.5em; 
     z-index:          2; 
     } 

     div.playerpopup 
     { 
     position:        absolute; 
     top:          100px; 
     left:          100px; 
     z-index:         100; 
     } 
    </style> 



    <script src="http://www.google.com/jsapi"></script> 
    <script type="text/javascript">google.load('swfobject', '2.2');</script> 
    <script type="text/javascript"> 
     var swf = false; 

     function addSwf(file, width, height, id) 
     { 
     clearSwf(); 

     if((id != '') && (id != undefined)) 
     { // alert('The '+gid(id).nodeName+' element with id="' + id + '"\nTop: '+gid(id).style.top + '\nLeft: ' +gid(id).style.left); 
      gid('playerpopup').style.top = ((gid(id).style.top.replace('px', '') * 1) - 500) + 'px'; 
      gid('playerpopup').style.left = ((gid(id).style.left.replace('px', '') * 1) + 60) + 'px'; 
      setTimeout("swf = true;", 1000); // alert('New nTop: '+gid('playerpopup').style.top + '\nLeft: ' +gid('playerpopup').style.left); 
     } 
     else 
     { 
      gid('playerpopup').style.top = 'px'; 
      gid('playerpopup').style.left = 'px'; 
      setTimeout("swf = true;", 1000); 
     } 

     gid('playerpopup').innerHTML='<a id="player"class="player"href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Adobe Flash Player</a><div><input type="button" style="width:'+width+'px;" value="-- C L O S E --" onclick="clearSwf(); return false;"></div>'; 

     var flashvars = 
     { 
      'file':         file, 
      'frontcolor':       'd3d3d3', 
      'backcolor':        '000000', 
      'lightcolor':       '6d6c6b', 
      'screencolor':       '373737', 
      'id':         'playerID', 
      'autostart':        'true' 
     }; 

     var params = 
     { 
      'allowfullscreen':      'true', 
      'allowscriptaccess':      'always', 
      'wmode':         'opaque', 
      'bgcolor':        '#FFFFFF' 
     }; 

     var attributes = 
     { 
      'id':         'playerID', 
      'name':         'playerID' 
     }; 

     swfobject.embedSWF('player.swf', 'player', width, height, '9.0.124', false, flashvars, params, attributes); 
     }; 


     function clearSwf() 
     { 
     if(swf) 
     { 
     swfobject.removeSWF('playerID'); 
     gid('playerpopup').innerHTML = ''; 
     swf = false; 
     } 
     }; 


     function gid(name) 
     { 
     return document.getElementById(name); 
     }; 
    </script> 

</head> 




<body bgcolor="white";> 


    <div id="12345" style=" position:absolute; top:606px; left:120px; width:180px; height:30px; z-index:19;"> 

    <img alt="Preview" src="Preview.jpg" width="80" height="60" onClick="addSwf('video.flv', 640, 503, this.parentNode.getAttribute('id'));" /> 

    </div> 

    <div id="playerpopup" class="playerpopup"> </div> 

</body> 

</html> 
0

我建议使用的fancybox:

http://fancybox.net/

他们有一个“SWF”的一个例子,我敢肯定,你可以为你自己的目的适应这一点。

+0

谢谢我看着这个和灯箱和其他一些花费大约50美元。他们没有做我所需要的。 – 2010-05-27 07:03:58

+0

当然:)它也被一些漂亮的主要网站使用,比如http://www.woot.com – 2010-05-27 07:05:27

0

我用Shadowbox.js之前,很高兴它(视频的例子是在主页上更低)。您可以嵌入YouTube视频,您自己的.flv文件(使用JW Player),Vimeo视频等。

此外,它不使用任何JavaScript框架,因此它可以保证与您的代码一起工作。

+0

我无法确定是否有可能避免页面模糊不清。没有回应支持... – 2010-05-27 07:46:46

+0

您可以通过JS激活ShadowBox并将showOverlay选项设置为false,或编辑实际的shadowbox.js并更改showOverlay:true以showOverlay:false – 2010-05-27 08:53:13