Forum Moderators: not2easy

Message Too Old, No Replies

Define Which Code Gets Displayed

         

newseed

4:53 pm on Mar 8, 2016 (gmt 0)

10+ Year Member



I have slidshow for desktop but I don't want to show that slideshow in mobile but instead I want a different slideshow specifically for mobile only. I do undertstand media query where I can hide one or the other depending on the devices but the problem is that mobile devices will still load both slideshows and I don't want to do that.

I need some kind of .asp code for condition to determine which slideshow gets displayed something like this:


<% If session("Mobile")="1" Then %>
---display mobile only slideshow---
<% Else %>
---display desktop only slideshow---
<% End If %>


Keep in mind that I don't need mobile redirect. I just need a way to define a certain set of html code for a specific condition.

not2easy

6:31 pm on Mar 8, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Sorry I'm not very helpful for "asp" environments, but wouldn't a media query in css be just as useful?

Something like:
@media (min-width:509px)
{
.otherclass
{
display: none;
}

.slideshow
{
display: block;
width: 96%;
}
}
and
@media (max-width:508px)
{
.slideshow { display: none; }

.otherclass
{
display: block;
width: 96%;
}
}

newseed

8:54 pm on Mar 8, 2016 (gmt 0)

10+ Year Member



I am aware of media query but just because you set it to display:none does not mean that the mobile device will not load all those images. Also, using background-images might not load the images but it will not work with slideshow since it has to use <img> tags.