ido435
Gebruiker
- Lid geworden
- 10 nov 2010
- Berichten
- 674
Hallo,
Ik ben bezig om een android en IOS app te maken maar ik zit nu met het volgende probleem.
als ik het scherm roteer moet hij een andere img laten zien maar dat doet hij namelijk niet.
[JS] <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<script>
$(document).ready(function () {
var width = $(window).width(); //get the width of the screen
screensize(width);
});
$(window).on("orientationchange", function () {
var width = $(window).width(); //get the width of the screen
screensize(width);
alert(width);
});
function screensize(width)
{
var width = $(window).width(); //get the width of the screen
$('#myImage').attr('src', '');
alert(width);
if (width >= 634)
{
$('#myImage').attr('src', 'img/logo/img5');
console.log("1");
}
if (width <= 634)
{
$('#myImage').attr('src', 'img/logo/img4');
console.log("2");
}
if (width <= 527)
{
$('#myImage').attr('src', 'img/logo/img3');
console.log("3");
}
if (width <= 425)
{
$('#myImage').attr('src', 'img/logo/img2');
console.log("4");
}
if (width <= 326) {
$('#myImage').attr('src', 'img/logo/img1');
console.log("5");
}
}
</script>[/JS]
ik heb de img namen even weggehaald.
mvg ido
Ik ben bezig om een android en IOS app te maken maar ik zit nu met het volgende probleem.
als ik het scherm roteer moet hij een andere img laten zien maar dat doet hij namelijk niet.
[JS] <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<script>
$(document).ready(function () {
var width = $(window).width(); //get the width of the screen
screensize(width);
});
$(window).on("orientationchange", function () {
var width = $(window).width(); //get the width of the screen
screensize(width);
alert(width);
});
function screensize(width)
{
var width = $(window).width(); //get the width of the screen
$('#myImage').attr('src', '');
alert(width);
if (width >= 634)
{
$('#myImage').attr('src', 'img/logo/img5');
console.log("1");
}
if (width <= 634)
{
$('#myImage').attr('src', 'img/logo/img4');
console.log("2");
}
if (width <= 527)
{
$('#myImage').attr('src', 'img/logo/img3');
console.log("3");
}
if (width <= 425)
{
$('#myImage').attr('src', 'img/logo/img2');
console.log("4");
}
if (width <= 326) {
$('#myImage').attr('src', 'img/logo/img1');
console.log("5");
}
}
</script>[/JS]
ik heb de img namen even weggehaald.
mvg ido
Laatst bewerkt: