2012-07-18 75 views
0

我想使用jQuery扫描html页面 - 在这种情况下由WordPress创建,以查找用户通过WP编辑管理员添加的所有vimeo视频链接。在使用jQuery筛选器的colorbox中打开vimeo url

然后我想将这些链接的控制权交给colorbox。

jQuery选择可与此链接:

http://vimeo.com/44799432

// vimeo in colorbox ## 
jQuery("a").filter(function(){ // filter all as ## 
    return jQuery(this).text().match(/vimeo\.com/igm); // match text with vimeo.com ## 
    }).colorbox({iframe:true, innerWidth: "80%", innerHeight: "80%"}) // assign to colorbox ## 
    .addClass("button vimeo"); // add class to style ## 

然而,VIMEO推动含量超出了iframe的,并重新加载页面 - 所以我需要一个正则表达式将匹配这个网址 - 可以通过iframe嵌入:

http://player.vimeo.com/video/44799432

match(/player.vimeo\.com/); 

不这样做 - 任何想法?

注:我显然需要一个循环来检查多个VIMEO链接...

谢谢!

+0

行 - 所以我只是学会了一些SOF如何工作 - 而现在有100%的速度 - 谢谢! – 2012-07-19 15:08:23

回答

1

试试这个(未经测试) >>

jQuery("a").filter(function() { 
    return jQuery(this).text().match(/vimeo\.com/igm); 
    }).each(function() { 
    this.setAttribute("href", this.getAttribute("href") 
    .replace(/^https?:\/\/(?:www\.|)vimeo\.com\/(\d+)$/i, 
     "http://player.vimeo.com/video/$1")); 
    }).colorbox({iframe:true, innerWidth: "80%", innerHeight: "80%"}) 
    .addClass("button vimeo"); 
+0

谢谢,但我没有看到相关性..最后我已经使用oembed,因为这可能会更容易,但目前似乎需要WP中的短代码...但它的工作原理。 – 2012-07-19 14:59:57

+0

你是说它是https? – 2012-07-20 14:35:06

+0

@QLStudio - 我不确定我们是否清楚你想要解析什么。我相信你正试图找出从短url版本到长版本的重定向url,上面的答案与解决方案一起提供。如果这不是你想要的,你应该通过编辑更多细节和/或示例来澄清你的问题。 – 2012-07-20 15:34:49

相关问题