开发者

jQuery Fancybox & Loading file using location.hash both not working

开发者 https://www.devze.com 2023-04-07 13:11 出处:网络
http://www.alphenweer.nl/index.php#page:alphen-afgelopenuur.php The first thing you will see is the first bug.

http://www.alphenweer.nl/index.php#page:alphen-afgelopenuur.php

The first thing you will see is the first bug.

I use the function getdata() located in my index.js file to call the page, and put it in the main DIV. That could be a problem, if anyone wants to link to a certain page people still have to click on another link. So i came up with this solution (that is also located in my index.js file:

function getdataonload(){
    var page = window.location.hash;
    if(window.location.hash != ""){
        page = page.replace('#page:', '');
        getdata('nosub/content/'.page);
    }
}

// and for the links:
<a href="#page:alphen-afgelopenuur.php">..</a>

But that doesn't seem to work properly. The div now gets filled with my main index.php file again. Why is this happening, what am i doing wrong?

And i also seem to have another bug wwith jQuery Fancybox. For example, go to the same link, click on "Ontladingen" and then select one of the links popping up. The source of those pages are almoast identical, but its like this:

<a href="link/to/image.png" class="fancybox">
    <img src="link/to/image.png" alt="example">
</a>

And then on the bottom of my page i 开发者_Go百科have this piece of code:

<script type="text/javascript">
    $("a.fancybox").fancybox();
</script>

Now it should work. But it isn't working. Why is that, and how can i solve that problem? Could you please all help me with both my problems?


For first problem-

you have to build full URL at getdata('nosub/content/'.page); . It should be like 'http:// ... nosub/content/'

For the 2nd problem -

You can try to write the code as follows -

<script type="text/javascript">
  $(document).ready(function() {
    $("a.fancybox").fancybox();
   });
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号