Get jQuery from masterpage working on contentpage

1.1k views Asked by At

I have a problem that my jQuery don't load or something when i'm on the contentpages.

When i click on the link that should load the jquery, it only works at my startpage (Default.aspx). And when i click at the same link that is placed in my footer on any other contentpage, nothing happens. So i guess something is wrong with the paths or the loading of my scripts.

I'm not so familiar with jQuery so hopefully someone can help me.

Here is my scripts in the masterpage .

<script type="text/javascript" src="../fancybox/jquery.fancybox-1.3.4.pack.js"</script>

<link href="../fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

    $(document).ready(function () {

        $(".inline").fancybox({
            'hideOnContentClick': true,
            'titlePosition': 'inside',
            'transitionIn': 'none',
            'transitionOut': 'none'
        });

    });
</script>

And this is what it calls, the footer in my masterpage.

<div id="footer"><a class="inline" href="#data">Viktor Nilsson</a></div>

<div style="display:none">
<div id="data">
Kontakta Viktor Nilsson<br />
Tel: 00000<br />
Email: [email protected] <br /><br /> 
</div></div>    
1

There are 1 answers

1
themarcuz On

You link the script files using ../fancybox/etc : this relative path could be wrong when opening a content page. Let's say your master is in the root folder and you content page is in a Content folder

webroot    
   |
   |-Master.aspx
   |-Content
   |    L contentPage.aspx
   L fancybox

the script should become ../../fancybox/etc...

For this reason, you'd better use

<script src='<%= Page.ResolveUrl("~/fancybox/jquery.fancybox-1.3.4.pack.js")%>' type="text/javascript"></script>

The same for the css link