1
我有以下腳本:如何一個網址更改爲另一個與jQuery
<script>
safari.application.addEventListener("command", performCommand, false);
function performCommand(event) {
if (event.command == "change") {
$('a[href="http://example.com"]').attr('href', 'http://sub.example.com');
}
}
</script>
而我希望發生的是,當按下菜單欄按鈕時,它運行在的代碼(在此case,('a[href="http://example.com"]').attr('href', 'http://sub.example.com');
),它找到所有鏈接並用修改後的版本替換它們。我怎樣才能做到這一點?
你能解釋你的問題的一些症狀嗎?什麼似乎是錯誤/無效/根本不工作? – 2011-02-11 21:16:54
那麼,當我用它作爲safari擴展時,它會調用腳本,但它不會調用該函數。 – Charlie 2011-02-11 21:26:07