Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 禁用事件单击以谷歌事件_Javascript_Events_Click_Fullcalendar - Fatal编程技术网

Javascript 禁用事件单击以谷歌事件

Javascript 禁用事件单击以谷歌事件,javascript,events,click,fullcalendar,Javascript,Events,Click,Fullcalendar,通过阅读FullCalendar上的文档,我想我可以找到一种方法来禁用单击事件,从而将浏览器引导到原始的Google日历。但由于未知原因,我使用的脚本没有禁用浏览器以打开新窗口 我对脚本还很陌生,所以我可能很容易犯错误。 这是我试图使用的,但不起作用,但 <script>$(document).ready(function() { // page is now ready, initialize the calendar... $('#calendar').fullCalendar(

通过阅读FullCalendar上的文档,我想我可以找到一种方法来禁用单击事件,从而将浏览器引导到原始的Google日历。但由于未知原因,我使用的脚本没有禁用浏览器以打开新窗口

我对脚本还很陌生,所以我可能很容易犯错误。 这是我试图使用的,但不起作用,但

<script>$(document).ready(function() {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
    // put your options and callbacks here
    weekNumbers: 'true',
    header: {
        left: 'title',
        center: '',
        right: 'today,prev,next,',
    },
    editable: 'true',
    eventSources: [
        {url: 'https://www.google.com/ca...',
        className: 'tehuur',
        },
            {url: 'https://www.google.com/cale...',
        className: 'verhuurd',
        },
    ],
    eventClick: function(event) {
        if (event.url) {
            window.open(event.url);
            return false;
        }
    }
})
$(文档).ready(函数(){
//页面现在已准备就绪,请初始化日历。。。
$(“#日历”).fullCalendar({
//把你的选择和回电放在这里
周数:'正确',
标题:{
左:'标题',
中心:'',
右图:“今天,上一个,下一个”,
},
可编辑:“true”,
事件来源:[
{url:'https://www.google.com/ca...',
类名:'tehuur',
},
{url:'https://www.google.com/cale...',
类名:“verhuurd”,
},
],
事件单击:函数(事件){
if(event.url){
window.open(event.url);
返回false;
}
}
})
}));

有人能给我指出正确的方向来禁用eventClick吗。谢谢你的帮助


Ben

只需删除eventClick功能

这一行打开了谷歌日历的一个新窗口:
window.open(event.url)

编辑:

如果要重定向而不是打开新窗口,应使用:
window.location.href=event.url

而不是
window.open(event.url)

你读过你发布的代码了吗?上面写着eventClick,它会打开一个新窗口等等。是的,这就是为什么我很惊讶,它仍然会在点击一个事件时引导我进入谷歌日历页面。我想禁用这个。我被告知,实现声明“returnfalse”的代码部分不会打开新的谷歌页面。然而,这似乎不起作用。也许有人可以帮助我禁用此事件,用不同的代码单击,或者显示我在上面的代码中做错了什么。感谢您的帮助……您是否真的在问如何重定向而不是打开一个新窗口?很难说谢谢Richard,因为他试图解决我的问题。正如您的代码在小提琴中显示的那样,议程项目仍然可以单击,单击时,在代码仍然保持不变的情况下(打开一个新窗口)开始。我的偏好是,议程中显示的任何项目都只显示,而不是可点击的链接。但这显然无法实现。从某种意义上说,如果新的方向不会返回到谷歌日历,那么重定向将是有帮助的。事件可以单击,但不会返回到任何地方。我认为这个问题在最低限度的理解或其他条件下可能是合格的。尽管如此,页面似乎仍在刷新,所以我在函数中添加了返回false。@BenvanWetten单击某个事件仍在打开新窗口吗?如果是,您使用的浏览器是什么?是的,单击事件仍会打开一个新窗口。在此窗口中,单击的Google事件显示在用作eventsource的公共Google日历中。(当登录到google帐户时,事件显示为可编辑,注销时显示事件的简单数据)当我使用不同形式的事件源(如各自页面脚本中的数组)时,正如您所提到的,事件也可以单击,但不会打开新窗口(单击后没有任何操作)。我已经在基于HTML5-bootstrap 2.2.2的网站设置中插入了FullCalendar脚本。除了我希望更改从eventSource google calendar中单击事件的操作之外,它工作得很好。
$(document).ready(function() {

    $('#calendar').fullCalendar({
        weekNumbers: 'true',
        header: {
            left: 'title',
            center: '',
            right: 'today,prev,next,',
        },
        editable: true,
        events: 'http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic',
        eventClick: function() {
            return false;
        }
    });

});
eventClick: function(event) {
  if (event.url) {
    if (event.url.includes('google.com')){
      return false;
    }
    console.log(event.url.includes('google.com'));

  }
}