[WordPress] 外掛分享: jQuery.autoTarget for WordPress

前言介紹

  • 這款 WordPress 外掛「jQuery.autoTarget for WordPress」是 2014-12-16 上架。 目前已經下架不再更新,不建議安裝使用。
  • 目前有 10 個安裝啟用數。
  • 上一次更新是 2018-04-12,距離現在已有 2579 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.0 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

billknechtel |

外掛標籤

target | automagic | standards compliance |

內容簡介

當您寫符合標準的代碼,但仍希望將外部鏈結在新窗口中打開時有一點需要特別注意。XHTML 1.0 Strict 已棄用 “target” 屬性,HTML5 早期版本也有這種棄用情況,但現在又重新引用了。在任何情況下,確保對每個外部連結都設置目標屬性可能很繁瑣。

輸入 jQuery.autoTarget

這個 jQuery 外掛程式可以自動掃描頁面上的所有鏈接,如果 href 屬性的域名與該頁面所在域名不同,它會自動為您設置 target 屬性(target=”_blank”)。為了讓您更方便地設置樣式,它還會將所有外部鏈接設置為 “external-link” 的類。這真是易如反掌,而且僅佔 272 字節的空間!

不會覆蓋

為了保險起見,該腳本不會修改已經設置目標屬性的鏈接,所以如果您已經對目標屬性進行了某些操作,它不會將您現有的工作覆蓋掉。

在非 WordPress 网站使用 jQuery.autoTarget

如果您需要,我的 jQuery 插件 sans WordPress 插件可在 https://github.com/wknechtel/jQuery.autoTarget 下載。

原文外掛簡介

There is a little gotcha when you’re writing standards compliant code, but still want off-site links to open in new windows. XHTML 1.0 Strict deprecated the use of the “target” attribute. Early versions of HTML5 also had this deprecation, but have since brought it back. In either case, making sure the target attribute is set on every off-site link can be tedious.
Enter jQuery.autoTarget
Instead of going through the tedium of ensuring your target attributes are set, this jQuery plugin automatically scans all the links on a page, and sets the attribute for you (target=”_blank”) if the href attributes domain isn’t the same as the domain the page is served from. Just to sweeten the deal, it also sets any offsite link to have a class of “external-link”, so you can style offsite links in the manner of your choice. Easy-peasy. And it only weighs in at 272 bytes!
No-clobber
Just in case, the script does not touch any link that already has a target set, so if you’re already doing something with the target attribute, this won’t clobber your extant work.
Use of jQuery.autoTarget in Non-WordPress Sites
If you need it, my jQuery plugin sans wordpress plugin is available at https://github.com/wknechtel/jQuery.autoTarget

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「jQuery.autoTarget for WordPress」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0.0 | trunk |

延伸相關外掛(你可能也想知道)

暫無相關外掛推薦。

文章
Filter
Mastodon