【发布时间】:2011-11-07 19:15:18
【问题描述】:
如果 YouTube iframe html 是
<iframe width="560" height="315" src="http://www.youtube.com/embed/VIDEOID" frameborder="0" allowfullscreen></iframe>
jquery 应该测试 iframe src 以查看前 29 个字符是否匹配 http://www.youtube.com/embed/
如果它确实应用 jquery 在/embed/ 之后提取VIDEOID 并将iframe src 替换为http://www.redirect.mysite.com/?id=VIDEOID
所以下面是 iframe 的 src
<iframe width="560" height="315" src="http://www.youtube.com/embed/EhrYQrLBiTQ" frameborder="0" allowfullscreen></iframe>
应该替换为
<iframe width="560" height="315" src="http://www.redirect.mysite.com/?id=EhrYQrLBiTQ" frameborder="0" allowfullscreen></iframe>
【问题讨论】: