使用URL更新和默认内容加载内容

时间:2014-05-21 20:46:35

标签: javascript jquery url plugins jquery-load

我有一个jQuery插件,可以将内容加载到某个div中。在开头忽略drawmap函数。它只在其中一个页面中提供。我在更新网址时尝试将内容加载到div中(不是重定向)。例如,如果我点击关于我们,网址将显示:calstateautoparts.com/beta/aboutus.html。如果我点击联系我们,网址将显示calstateautoparts.com/beta/contactus.html。

另外,我想让插件默认加载div中的页面,home.html。如何在我的代码中进行这两项更改?

您可以在http://calstateautoparts.com/beta

查看实际网站
<script type="text/javascript">
jQuery(function($){
    function drawmap(){
        new Maplace({
                    locations: [
                        {
                            lat: 33.8583,
                            lon: -117.8678,
                            title: 'Anaheim',
                            html: [
                                '<h3>Anaheim</h3>',
                                '<p>1361 N RedGum St, Anaheim CA 92806<br>(714) 630-5954</p>'
                            ].join(''),
                            zoom: 8
                        },
                        {
                            lat: 34.2358,
                            lon: -118.5739,
                            title: 'Chatsworth',
                            html: [
                                '<h3>Chatsworth</h3>',
                                '<p>20233 Corisco St, Chatsworth CA 91311<br>(818) 998-3001</p>'
                            ].join(''),
                            zoom: 8
                        },
                        {
                            lat: 32.8142,
                            lon: -117.1247,
                            title: 'San Diego',
                            html: [
                                '<h3>San Diego</h3>',
                                '<p>4000 Ruffin Road Suite K, San Diego CA 92123<br>(858) 292-1622</p>'
                            ].join(''),
                            zoom: 8
                        }
                        ,
                        {
                            lat: 34.9137,
                            lon: -120.4632,
                            title: 'Santa Maria',
                            html: [
                                '<h3>Santa Maria</h3>',
                                '<p>1459 W. Fairway Dr., Santa Maria CA 93455<br>(805) 922-4445</p>'
                            ].join(''),
                            zoom: 8
                        }
                        ,
                        {
                            lat: 34.5011,
                            lon: -117.3279,
                            title: 'Victorville',
                            html: [
                                '<h3>Victorville</h3>',
                                '<p>15400-B Tamarack Road, Victorville CA 92392<br>(760) 243-5666</p>'
                            ].join(''),
                            zoom: 8
                        }
                        ,
                        {
                            lat: 36.1605,
                            lon: -115.1050,
                            title: 'Las Vegas',
                            html: [
                                '<h3>Las Vegas</h3>',
                                '<p>3101 Builders Ave., Las Vegas, NV 89101<br>(702) 452-2440</p>'
                            ].join(''),
                            zoom: 8
                        }
                        ,
                        {
                            lat: 33.1677,
                            lon: -117.2202,
                            title: 'Vista',
                            html: [
                                '<h3>Vista</h3>',
                                '<p>2055 Thibodo Rd, Vista CA 92081<br>(760) 599-0791</p>'
                            ].join(''),
                            zoom: 8
                        }
                        ,
                        {
                            lat: 33.6224,
                            lon: -117.7194,
                            title: 'Laguna Hills',
                            html: [
                                '<h3>Laguna Hills</h3>',
                                '<p>23561 Ridge Route Suite P, Laguna Hills CA 92653<br>(949) 699-3308</p>'
                            ].join(''),
                            zoom: 8
                        }
                        ,
                        {
                            lat: 34.4245,
                            lon: -118.4998,
                            title: 'Santa Clarita',
                            html: [
                                '<h3>Santa Clarita</h3>',
                                '<p>26846 Oak Ave Unit R, Santa Clarita CA 91315<br>(661) 424-9396</p>'
                            ].join(''),
                            zoom: 8
                        }
                    ],
                   map_div: '#gmap-list',
                   controls_type: 'list',
                controls_title: 'Choose a location:'
                }).Load();
    }
    $('.menuitem').click(function(e){
        $('#contentarea').load(this.href, $(this).data('loadfunc') || null);
        e.preventDefault();
    });
    $('#contactus').data({loadfunc: drawmap});
});
        </script> 

0 个答案:

没有答案