修改“x”;高幻灯片弹出的关闭按钮

Modifing the "X" close button of highslide popups

本文关键字:关闭按钮 幻灯片 修改      更新时间:2023-09-26

我将hililide与highcharts结合使用,我想修改关闭按钮,更具体地说,我想在用户单击"X"按钮时调用一个附加函数。

当我检查"X"按钮时,我在控制台得到这个

<a href="#" title="Close (esc)" onclick="return hs.close(this)"><span>Close</span></a>

我想做这样的事情

<a href="#" title="Close (esc)" onclick="return hs.close(this);myotherfunction();"><span>Close</span></a>

但是我无法找到代码所在的位置。

我已经尝试将此添加到我的html文件本身的头,除了hililide.config.js手动覆盖,但它没有工作。

hs.registerOverlay({
   html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
   position: 'top right',
   fade: 2 // fading the semi-transparent overlay looks bad in IE
});
有谁能帮帮我吗?

//////////////////////////////更新多亏了Jeff B,我才能够使用如下所示的代码完成预期的任务(尽管Jeff B展示的示例也可以工作):

cursor: 'pointer',
point: {
    events: {
        click: function(event) {
            hs.htmlExpand(null, {
                pageOrigin: {
                    x: this.pageX,
                    y: this.pageY
                },
                headingText: this.ticker,
                maincontentText: '<b>Detail:</b> ' + this.info,
                width: 250
            });
            alert('function goes here');
            hs.Expander.prototype.onBeforeClose = function(sender) {
                alert('function goes here');
            }               
        },
    }
},

为什么要修改按钮?Hililide提供了一个onBeforeClose原型:

hs.Expander.prototype.onBeforeClose = function (sender) {
   myotherfunction();
}

如果你想要不同的时间,也有一个onAfterClose原型。

onBeforeClose文档

演示:http://jsfiddle.net/xjKFp/