WordPress.org

Ready to get started?Download WordPress

Forums

Scroll Triggered Boxes
[resolved] Open on certain browser possible? (5 posts)

  1. esucces
    Member
    Posted 4 months ago #

    Hi Danny

    Would it be possible to trigger a box on a certain browser, eg IE 9?

    That would be awesome :-)

    Cheers,
    Jan

    https://wordpress.org/plugins/scroll-triggered-boxes/

  2. Danny van Kooten
    Member
    Plugin Author

    Posted 4 months ago #

    Hi Jan,

    Yes, you should be able to do such a thing by adding the following code snippet to your theme its functions.php file.

    function my_prefix_show_box_in_ie($show, $box_id) {
    
     	// change 123 to the ID of the box you want to show on IE only
    	if( $box_id !== 123 ) {
    		return $show;
    	}
    
    	$show = preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']);
    
    	return $show;
    }
    
    add_action('stb_show_box', 'my_prefix_show_box_in_ie', 10, 2);

    Hope that sets you off in the right direction, good luck!

  3. esucces
    Member
    Posted 4 months ago #

    Hi Danny

    That snippet works, but ignores the defined rule of the box:
    If page is = 25,26.

  4. Danny van Kooten
    Member
    Plugin Author

    Posted 4 months ago #

    Hi Jan,

    Wasn't sure whether you wanted that. If you want to preserve the defined box rules, use the following.

    function my_prefix_show_box_in_ie($show, $box_id) {
    
     	// change 123 to the ID of the box you want to show on IE only
    	if( $box_id !== 123 || $show === false ) {
    		return $show;
    	}
    
    	$show = preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']);
    
    	return $show;
    }
    
    add_action('stb_show_box', 'my_prefix_show_box_in_ie', 10, 2);
  5. esucces
    Member
    Posted 3 months ago #

    Worked perfectly :-)

Reply

You must log in to post.

About this Plugin

About this Topic