0

我当前的代码提取 YouTube 视频的视频 ID 并将其嵌入到自己的页面中:

document.location = 'http://www.youtube.com/embed/' + document.location.href.match(/[&?]v=([^&#]*)/i)[1]

我想添加在视频 ID 之后添加三个 YouTube 参数“?modestbranding=1&rel=0&autoplay=1”的代码,使其变为:

http://www.youtube.com/embed/[VIDEOID]?modestbranding=1&rel=0&autoplay=1

如何才能做到这一点?

4

1 回答 1

1

只需要添加到您的 document.location 分配的其余部分:

document.location = 'http://www.youtube.com/embed/' + document.location.href.match(/[&?]v=([^&#]*)/i)[1] + "?modestbranding=1&rel=0&autoplay=1"
于 2013-07-03T20:20:50.993 回答