v2.5.2
Giriş yap

javascript içinden php ye değişken değeri atama

pcmemo
2,426 defa görüntülendi

Merhaba arkadaşlar aşağıdaki javascript anlık olarak tarayıcının boyutunu gösteriyor.
Bu javascript içinde yükseklik ve genişlik değerlerini birer php değişkenine atayabilir miyiz?

<p id="ViewPortSize"> </p>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<script>
function GetViewPortSize() {
$('#ViewPortSize').text("Width = " + $( window ).width() + " / Height = " + $( window ).height());   /* <!doctype html> may be necessary */
}

/* Execute "GetViewPortSize" function at page load */
$(GetViewPortSize);

/* Execute "GetViewPortSize" function everytime the browser viewport is resized */
$( window ).resize(GetViewPortSize);
</script>
tayfunerbilen
2043 gün önce

front-end tarafını ilgilendiren konularda php yerine css'i kullanabilirsin. neden @media sorgularını kullanarak bunu yapmıyorsun?

iframe.youtube-video {
    width: 700px;
    height: 300px;
}
@media(max-width: 700px){
    iframe.youtube-video {
        width: 100%;
        height: 280px;
    }
}

gibi..