我有一张卡,我希望用户能够通过使用鼠标中键在新选项卡中打开它。为此,我添加了一个带有为每张卡自动生成的href的链接<a>。问题是,我试图导航到的路由将一些复杂的结构作为参数,这些结构不能直接在路由链接中传递。有时用户只需点击卡片,浏览器就会获取链接,而不是传递参数的js方法。结果,新的路由被加载,就像没有参数的地方(如果它在新的选项卡中,这是正确的行为)。 const openDocument = function (){
console.log('open doc in the same tab using custom router params')
在下面的脚本中如何调用disableRightClick函数,声明document.oncontextmenu=disableRightClick做了什么?请解释一下。
document.oncontextmenu = disableRightClick;
// how this function is called
function disableRightClick(event) {
event = event || window.event;
if (event.preventDefault) {
event.preventDefault();
} else {
我注意到鼠标右键单击火狐会触发一个addEventListener。
我尝试在更多的浏览器和更多的操作系统(IE11-10-9,Safari,Chrome)和鼠标右键点击,只有在火狐的console.log消息总是打印。
<div id="one-div" style="height:400px;width:500px;background-color:#000;"> click me </div>
<script>
function cb(event, from){
// if click is fi