我不知道如何正确地表达这个标题来解释我需要帮助的地方,所以这是我的故事。
下面的代码编写了一个包含视频的iframe:
<script type="text/javascript" src="http://sv.liveclicker.net/service/getEmbed?client_id=1915&widget_id=1372752183&player_custom_id=2264&height=450&width=800&autoplay=false"></script>我不能直接更改上面的脚本,所以我如何删除该脚本(以及生成的iframe),然后使用修改后的参数(高度和宽度)再次调用该脚本,以便用我的新尺寸写出新的iframe/视频-而且不需要刷新页面(好吧,刷新只会取消任何更改并再次恢复到旧脚本)。
顺便说一句,client_id、widget_id和player_custom_id需要与页面上的原始内容保持一致。
如果这可以用jQuery实现,那就太棒了(刚刚开始学习)。
感谢大家的帮助。
附加信息:在chrome中,当我单击脚本src时,它会显示以下内容:
if (!window.liveclicker) window.liveclicker = {};
if (!window.liveclicker || !liveclicker.receiveMessage) {
var lcs = document.createElement('script');
lcs.src = "http://sv.liveclicker.net/service/scripts/html5_js_c.js";
lcs.type = "text/javascript";
document.getElementsByTagName('head')[0].appendChild(lcs);
}
document.write('<iframe id="video_1372752183" name="video_1372752183" src="" width="800" height="450" frameBorder="0" scrolling="no" style="border:0;" webkitAllowFullScreen mozAllowFullScreen allowFullScreen></iframe>');
liveclicker.post_to_name = function (path, params, name) {
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", path);
form.setAttribute("target", name);
for (var key in params) {
if (params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
};
liveclicker.post_to_name("//player.liveclicker.com/video-player/index.php\?widget_id=1372752183&accountid=1915&urlaccount=http://www.dhccare.com&accountCDN=http://ecdn.liveclicker.net/0079A8/cdn/&setrefererURL=http%3A%2F%2Fdhcstaging.liveclicker.com%2F&navfile=TODO&iframeDiv=video_1372752183&channel=0&player_custom_id=2264", {
'shopapp_gview_buynow_avail': 0,
'knobsEnabled': 'false',
'shopapp_dview_buynow_avail': 0,
'shareAvailable': 'false',
'pseudo_streaming': 'true',
'snapshotFeaturev2': 0,
'buyAvailable': 'false',
'navBuyNow': 'false',
'aspectRatio': '16:9',
'autostart': 'false',
'ratingAvailablev2': 'false',
'mosaic_skin': 'true',
'sizing': 'crop',
'channel': 2
}, "video_1372752183");再次感谢!
发布于 2014-04-29 23:15:55
是否可以将脚本标记包装在一个div (id = "myDiv")中,然后使用innerHTML加载新视频/删除之前的视频,如下所示?
//Video1
<div id="myDiv">
<script type="text/javascript" src="http://sv.liveclicker.net/service/getEmbed?
client_id=1915&widget_id=1372752183&player_custom_id=2264&height=450&width=800&autoplay=false"></script>
</div>然后调用函数onclick按钮或图标来加载新视频:
//New script here...not sure what your script would be so I just put previous one..you can add height and width as parameters onclick...num1 and num2 would be what you need them to be
<button type="button" onclick="changeVideo(num1, num2)">Click</button>
function changeVideo(height, width) {
document.getElementById("myDiv").innerHTML = '<script type="text/javascript"
src="http://sv.liveclicker.net/service/getEmbed?client_id=&widget_id=1372752183&player_custom_id=2264&height=' + height + '&width=' + width + '&autoplay=false"></script>';
}https://stackoverflow.com/questions/23367821
复制相似问题