十二月 18 2006

Profile Image of evenrain
evenrain

客製化你的 SPA

Posted at 10:18:51 under frisch

我也想去做 SPA,可惜這邊指的是 Snap Preview Anywhere。不知道你開始使用了嗎?

Because so many sites have asked about it, we’re now offering a number of customization options to the Snap Preview Anywhere, including:

* Turning on previews on internal links
* Turning off previews on specific links

Snap 官方接獲許多網站的要求,增加了一些設定,我們就來看看多了些什麼吧。

原先我們看到的 SPA code 會是像這樣:

<script defer=”defer” id=”snap_preview_anywhere” type=”text/javascript” src=”http://spa.snap.com/snap_preview_anywhere.js?ap=1
&key=SAMPLE_KEY&sb=1&domain=www.example.com”></script>

如果你不想顯示 Search Bar,就把 ’sb=1′ 改為 ’sb=0′,結果如下:

<script defer=”defer” id=”snap_preview_anywhere” type=”text/javascript” src=”http://spa.snap.com/snap_preview_anywhere.js?ap=1
&key=SAMPLE_KEY&sb=0&domain=www.example.com”></script>

原先 Snap 會將「所有」的外部連結都加上預覽的功能,如果有些連結不想有預覽功能呢?你可以在不想有預覽的連結加上 ’snap_nopreview’ 這個 class:

<a class=”snap_nopreview” href=”http://www.example.com”>www.example.com</a>

那如果你只想在部份的連結加上預覽的功能呢,總不會是要一一用上面的方法排除掉吧?幸好不是(笑)。首先將 ‘ap=1′ 這個參數改為 ‘ap=0′,如此系統不會自動幫你的連結加預覽的功能,

<script defer=”defer” id=”snap_preview_anywhere” type=”text/javascript” src=”http://spa.snap.com/snap_preview_anywhere.js?ap=0
&key=SAMPLE_KEY&sb=0&domain=www.example.com”></script>

然後在你想要有預覽功能的連結加上 ’snap_preview’ 這個 class:

<a class=”snap_preview” href=”http://www.example.com”>www.example.com</a>

Snap 預設是會關閉站內連結的預覽,如果你希望連站內的連結都一併有預覽功能,你可以加上 ’si=1′ 這個參數。需要注意的是,這個參數不會關閉外部的連結預覽功能。

<script defer=”defer” id=”snap_preview_anywhere” type=”text/javascript” src=”http://spa.snap.com/snap_preview_anywhere.js?ap=1&si=1
&key=SAMPLE_KEY&sb=0&domain=www.example.com”></script>

就是這樣,試試看吧 :)

標籤:, ,

相關文章

No responses yet

Trackback URI | Comments RSS

Leave a Reply