0

我想在页面加载后加载jReject脚本。在默认的 jReject 脚本中,它适用于单击,我希望在页面加载时使用它。应该做出哪些改变来实现这一目标?我应该把 $(function() { $.reject(); });

这是我在标题中的脚本:

$(function() {
    // Handle external links
    $('a[rel="external"]').click(function() {
        var href = $(this).attr('href');

        // Send external link event to Google Analaytics
        try {
            _gaq.push(['_trackEvent','External Links', href.split(/\/+/g)[1], href]);
        } catch (e) {};

        window.open(href,'jr_'+Math.round(Math.random()*11));
        return false;
    });

    // Handle displaying of option links
    $('em.option').css({
        cursor: 'pointer',
        fontSize: '1.1em',
        color: '#333',
        letterSpacing: '1px',
        borderBottom: '1px dashed #BBB'
    }).click(function() {
        var self = $(this);
        var opt = $.trim(self.text());

        $('ol.dp-c:first').children('li').children('span').each(function() {
            var self = $(this);
            var text = self.text();
            var srch = opt+':';

            // If found, highlight and jump window to position on page
            if (text.search(srch) !== -1) {
                self.css('color','red');
                window.location.hash = '#c-'+opt;
                window.scrollTo(0,self[0].offsetTop);
            }
        });
    });

    /* Demo Codes */

    $('#demo3').click(function() {
        $.reject({
            reject: { all: true }, // Reject all renderers for demo
            header: 'Your browser is not supported here', // Header Text
            paragraph1: 'You are currently using an unsupported browser', // Paragraph 1
            paragraph2: 'Please install one of the many optional browsers below to proceed',
            closeMessage: 'Close this window at your own demise!' // Message below close window link
        }); // Customized Text

        return false;
    });

});
4

3 回答 3

0

就在您的 OP 中链接的底部:

负载运行(默认选项):

$(function() { $.reject(); });
于 2013-01-09T14:39:48.397 回答
0

来自文档:

加载时运行(默认选项): $(function() { $.reject(); });

于 2013-01-09T14:39:52.323 回答
0

转你的代码

$('#demo3').click(function() {
    $.reject({
        reject: { all: true }, // Reject all renderers for demo
        header: 'Your browser is not supported here', // Header Text
        paragraph1: 'You are currently using an unsupported browser', // Paragraph 1
        paragraph2: 'Please install one of the many optional browsers below to proceed',
        closeMessage: 'Close this window at your own demise!' // Message below close window link
    }); 
    return false;
});

进入

$.reject({
        reject: { all: true }, // Reject all renderers for demo
        header: 'Your browser is not supported here', // Header Text
        paragraph1: 'You are currently using an unsupported browser', // Paragraph 1
        paragraph2: 'Please install one of the many optional browsers below to proceed',
        closeMessage: 'Close this window at your own demise!' // Message below close window link
    });
于 2014-05-27T05:19:52.513 回答