1
我已經構建了一個使用colorbox來顯示圖像的投資組合網頁。我希望能夠從發送給人的外部鏈接直接鏈接到該頁面上的colorbox。如何從外部鏈接直接鏈接到彩盒?
有沒有人有任何想法我可以如何實現這一目標?
我已經構建了一個使用colorbox來顯示圖像的投資組合網頁。我希望能夠從發送給人的外部鏈接直接鏈接到該頁面上的colorbox。如何從外部鏈接直接鏈接到彩盒?
有沒有人有任何想法我可以如何實現這一目標?
確保每個圖像鏈接都有一個唯一的ID,例如, <一個ID =「照片1」 HREF =「PHOTO1.JPG」 >
添加像這樣到您的文檔準備功能,顏色框初始化代碼後:
if (location.hash) {
var link = $(location.hash); // location.hash includes "#" in front
// change the hasClass() test below to match your image links only
if (link.length > 0 && link.hasClass('colorbox')) {
link.click(); // trigger colorbox
}
}
然後附加到ID發送鏈接該網址,例如http://example.com/#photo1
這個(非常笨拙的)黑客工作,因爲URL錨點哈希也是jQuery中的id選擇器。 但是請注意,如果圖像的id是它的文件名,那麼你很可能不得不逃離它中的點,因爲它是jQuery中的選擇器:var link = $(location.hash.replace ( 「 」「 \\。」)); ''' – nojhan 2014-02-17 23:46:52