我通過 JavaScript 在我的導(dǎo)航欄上添加了 4 個(gè)鏈接。如何通過在我的提要中按 1-4 鍵來加載這些鏈接<iframe>?<li> <script type="text/javascript"> document.write('<a href="https://linkhere.com/blah.html?'+new Date().getTime()+'" target="feeds">1</a>');</script></li><iframe name="feeds" width="50%" height="500"></iframe>
1 回答

慕標(biāo)琳琳
TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊
看看這段代碼:
document.addEventListener('keypress', function (event) {
if (event.key === '1')
document.getElementsByName('feeds')[0].src =
'https://linkhere.com/blah.html?'+new Date().getTime();
});
<iframe name="feeds" width="50%" height="500"></iframe>
在這里,我們正在為鍵“1”設(shè)置鍵盤快捷鍵。以類似的方式,您可以為其他鍵添加鍵盤快捷鍵。
添加回答
舉報(bào)
0/150
提交
取消