如何将动态网址传递给iframe?

时间:2012-04-30 08:08:34

标签: jquery html

我必须将Eval("link")传递给iframe标记。这个eval("link ")表示最近在视频库中上传的视频,我只想在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 :(得分: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>
相关问题