2012-04-30 115 views
0

我必須將Eval("link")轉換爲iframe標記。這eval("link ")意味着在視頻庫上傳最近的視頻,我只是想表明在iframe中最近的項目:如何將動態url傳遞到iframe?

<iframe title="YouTube video player" width="525" height="325" src='<%# Eval("link") %>' frameborder="0" ></iframe> 

它不工作的罰款這裏是我的代碼:

function OpenDialog() { 
    var options = { 
     url: '/Shared%20Documents/Forms/AllItems.aspx', 
     title:Test modal dialogue, 
     width: 1100, 
     height: 600, 
     left: 50, 
     top: 50, 
     status: 0, 
     toolbar: 0, 
     menubar: 0, 
     resizable: 1, 
     dialogReturnValueCallback: CloseCallback 
    }; 

    SP.UI.ModalDialog.showModalDialog(options); 
    SP.UI.Modal.OpenPopUpPage('Home.aspx', CloseCallback, 1100, 600); 
} 

function autoPlayVideo(vcode, width, height) { 
    "use strict"; $("#videoContainer").html('<iframe width="' + width + '" height="' + height + '" src="https://www.youtube.com/embed/' + vcode + '?autoplay=1&loop=1&rel=0&wmode=transparent" frameborder="0" allowfullscreen wmode="transparent"></iframe>'); 
} 

jQuery('a.introVid').click(function() { autoPlayVideo('Eval("link")', '450', '350'); }); 

function CloseCallback(result, returnValue) { 
    alert('Result from dialog was: ' + result); 
    if (result == SP.UI.DialogResult.Ok) { 
     alert('You clicked Ok'); 
    } 
    else if (result == SP.UI.DialogResult.cancel) { 
     alert('You clicked Cancel'); 
    } 
} 
+1

什麼是「鏈接」?它來自服務器嗎? –

+0

您可以發佈您的ASP代碼生成的HTML。我猜測'Eval(「link」)'沒有返回一個值。 –

+0

Eval(「鏈接」)應該從資產庫返回值... – user1328195

回答

0

代碼:

<!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 runat="server"> 
    <title></title> 
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
     $(document).ready(function() { 
      $('a.introVid').live('click', function (e) { 
       e.preventDefault(); 
       autoPlayVideo($(this).data('vcode'), '450', '350'); 
      }); 
     }); 

     function autoPlayVideo(vcode, width, height) { 
      $("#videoContainer").html('<iframe width="' + width + '" height="' + height + '" src="https://www.youtube.com/embed/' + vcode + '?autoplay=1&loop=1&rel=0&wmode=transparent" frameborder="0" allowfullscreen wmode="transparent"></iframe>'); 
     }; 
    </script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <a class="introVid" href="#test" data-vcode="u1zgFlCw8Aw">Test Ypu Tube Video</a> 
     <div id="videoContainer"> 
     </div> 
    </div> 
    </form> 
</body> 
</html> 
+0

URl請參閱此鏈接:http://jsfiddle.net/nanoquantumtech/fDA7z/ – Thulasiram

相關問題