SVG css3 transition on fill not working when there is external link

后端 未结 4 856
孤独总比滥情好
孤独总比滥情好 2021-01-05 18:30

I have a problem similar to this one : here.

Only difference is that the page I want to link the SVG to is an external page meaning : http://www.google.ca

C

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-05 18:34

    This is actually something to do with the visited state. The reason the other commenters are saying it works is because they haven't been to your pages before. Once they have it will no longer work. I've tried adding visited states in the CSS and it makes no difference.

    The easiest solution I've found is to just add a random query string to the url so the page is effectively not visited eg:

    My Link

    Most sites will ignore a query they don't recognise so that should be ok. Or better would be to remove it with JS on click.

    $('body').on('click', 'a', function(e) {
        e.preventDefault();
        var url = $(this).prop('href');
        window.location.href = url.split("?")[0];
    });
    

提交回复
热议问题