在JS的左下角显示网址显示? [英] Show url display in bottom-left by JS?
问题描述
是否有通过 Javascript 在页面左下方显示网址的技巧?
Is there any trick to displaying url on bottom left of page by Javascript ?
示例我的链接元素是:
<div data-link="http://stackoverflow.com"></div>
JS:
$(document).on('click','[data-link]',function(){
var url = $(this).attr('data-link');
window.open(url,'_blank');
}).on('mouseover','[data-link]',function(){
var a = document.createElement('a');
a.href = $(this).attr('data-link');
$(a).trigger('mouseover');
// Nothing showing
});
可能吗?任何技巧?
推荐答案
据我所知,这是Javascript不可能的,这是一个浏览器特定的功能,只触发当你的鼠标悬停在链接上时如果用JS触发.hover(),它仅应用CSS规则并触发JS函数。
As far as I know this is not possible with Javascript, this is a browser-specific function that only triggers when your mouse hovers over a link. If you trigger the .hover() with JS, it "only" applies the CSS-Rules and fires the JS-Functions.
你可以创建一个绝对定位的div链接标记,当您将鼠标悬停在某个元素上时会显示此信息,但当您将鼠标悬停在实际的A-Tag上时可能会出现问题,那么您的div将隐藏在浏览器字段下。
You could create an absolute positioned div with the link-tag and show this when you hover over an element, but it could cause problems when you hover over an actual A-Tag, then your div will get hidden under the browser-field.
这篇关于在JS的左下角显示网址显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!