开发者

Confusing situation but I guess a CSS that "hides" entirely a div is my answer

开发者 https://www.devze.com 2023-02-22 04:56 出处:网络
My situation is this. I run a Wordpress blog. All the external links have a top bar on them with info about my page. The top bar is triggered when the link has this form www.mydomain.com/?www.theirdom

My situation is this. I run a Wordpress blog. All the external links have a top bar on them with info about my page. The top bar is triggered when the link has this form www.mydomain.com/?www.theirdomain.com and are automatically changed to bit.ly when they are posted through facebook.

However I decided to give fancybox Iframe a chance. So this is where I have two situations.

  1. Pages visited through facebook, twitter etc must have the top bar.
  2. Pages visited from the homepage must open with fancybox.

The problem is that I don't want the top bar to be appeared inside the fancybox (through the homepage) and I can't think of a solution. Links are the same on both situations and must not be changed at any case.

The开发者_StackOverflow社区 top bar uses a div with id wpbar, maybe if there is a way to hide it and avoid programming would be the best choice.

But if is not, then I have no chance. What about headers with a special string?

This is the code from fancybox.

<script type="text/javascript">
    $(document).ready(function() {
        $("a.popup").fancybox({
            'width'             : '75%',
            'height'            : '75%',
            'autoScale'         : false,
            'transitionIn'      : 'none',
            'transitionOut'     : 'none',
            'type'              : 'iframe'
        });
    });
</script>


If i got you right, when the page is inside your own domain, to hide all of the wordpress headers', is that correct?

Then you'll must have two calls to fancybox, one for internal pages and one for external

As links to external pages start with http://, and internal links can be relative, you can use this to filter the calls

 $(document).ready(function() {
        $("a.popup[href^='http://']").fancybox({
            'width'             : '75%',
            'height'            : '75%',
            'autoScale'         : false,
            'transitionIn'      : 'none',
            'transitionOut'     : 'none',
            'type'              : 'iframe'
        });

        $("a.popup:[href^='http://']").fancybox({
            'width'             : '75%',
            'height'            : '75%',
            'autoScale'         : false,
            'transitionIn'      : 'none',
            'transitionOut'     : 'none',
            'content'           : function(){
                //specify the html content you want to load, which you will get from a different page
                 $.load($(this).attr('href') + " #content"); 

                 // change #content for the div that holds the data you want to load.
                 // this will load only the html fragment, for example $.get('/page.html body') gets only 
                 // what's inside body
            }
        });
    });

This code may not be working, as I haven't tested, but I think you can get the idea


Did you try CSS display:none? See "any google result for css display none" for details. I might have misunderstood the question, if so, feel free to ignore ; )

0

精彩评论

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