S
S
Stas20202020-02-19 09:54:44
JavaScript
Stas2020, 2020-02-19 09:54:44

How to block script execution in responsive design?

The html page has pictures. When you click on an image, a script is executed that enlarges the image.
Through css and media for the page, there are several options. What is the easiest way to make sure that the script is not executed on the mobile version (i.e. the picture does not increase)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anita Kovaleva, 2020-02-19
@Stas2020

Find this piece of code with the script and fulfill the condition

function windowSize(){
    if($(window).width() >'768'){
                 <code>код</code>
    // экран больше 768 px в ширину --- выполняем скрипт
       }
}
$(window).load(windowSize);
$(window).resize(windowSize);
$(window).on('load resize',windowSize);

A
Alex, 2020-02-19
@Kozack

On the server, determine that this is a mobile version and do not give scripts for pictures.
Or
On the client, determine that this is a mobile version and do not run the script for pictures

E
Eugene, 2020-02-19
@iamd503

place a transparent block on top of the image block, which will be visible only on the mobile version

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question