我正在嘗試在由 http://localhost:8080 提供的網(wǎng)頁上注冊(cè)自定義協(xié)議處理程序這是我的代碼:<script> navigator.registerProtocolHandler("web+did", "http://localhost:8080?did=%s", "did search");</script><a href="web+did://123456">Search DID</a>但是當(dāng)我單擊鏈接時(shí),網(wǎng)絡(luò)瀏覽器只是將請(qǐng)求顯示為“已取消”,為什么它沒有被調(diào)度為“http://localhost:8080?did=123456”?
1 回答

犯罪嫌疑人X
TA貢獻(xiàn)2080條經(jīng)驗(yàn) 獲得超4個(gè)贊
在Firefox中,只有當(dāng)它包含在語句中,或者在由某些用戶交互顯式調(diào)用的函數(shù)中執(zhí)行時(shí),它才會(huì)起作用(即單擊一個(gè)按鈕,該按鈕調(diào)用一個(gè)函數(shù),該按鈕注冊(cè)一個(gè)協(xié)議處理程序)。navigator.registerProtocolHandler
window.onload
在 Chrome 中,不能自動(dòng)執(zhí)行,它需要在某個(gè)用戶交互調(diào)用的函數(shù)中執(zhí)行。我沒有任何文檔鏈接來支持這一點(diǎn),我只是通過自己的實(shí)驗(yàn)才發(fā)現(xiàn)這一點(diǎn)。navigator.registerProtocolHandler
- 1 回答
- 0 關(guān)注
- 164 瀏覽
添加回答
舉報(bào)
0/150
提交
取消