Hello! The main idea is that i want to set the variable for screen resolution of the user and pass it to php to manipulate her. How can i achieve that?

Recommended Answers

All 8 Replies

You cannot pass a javascript variable to php directly.

Is this what your looking for?

var myVar = <?php echo $phpVar; ?>

so the idea is to change the value at <link href="value to change depending on user resolution"> so i tought somehow to set the variables of screen resolution in js and get them with php so i can include the php in <link href="php to include">

You can use ajax for that (if it is worth the trouble). See jquery ajax.

so the idea is to change the value at <link href="value to change depending on user resolution"> so i tought somehow to set the variables of screen resolution in js and get them with php so i can include the php in <link href="php to include">

Another way of doing it is using Javascript to store the screen resolution to a hidden fields (width and height) in a form that has get as a method. This way the server will get the resolution in a $_GET array. Please note, the form has to be submitted somehow.

Yet another way is using a cookie.

Why did i got my comment voted down ?

Why did i got my comment voted down ?

I can't see any downvotes on your comment.

commented: it had dissapeared :) +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.