- Posts: 40
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Checking if a survey is opened via mobile device?
- DanielVN
- Topic Author
- Offline
- Senior Member
Less
More
5 years 11 months ago #168703
by DanielVN
Replied by DanielVN on topic Checking if a survey is opened via mobile device?
Awesome Thanks a lot to all of you.
The topic has been locked.
- orvil
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
5 years 11 months ago #168704
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Checking if a survey is opened via mobile device?
Hi,
simplest way:
A - decide which info is required
1.) create a new question (textarea)
2.) use the "Source" button in the Question editor
3.) copy and paste joffm's script (it gives you more information than mine) into the editor area
3) save the question an run it
You will see something like this:
B - delete the output not necessary for you. E.g. if you only need the mobile flag, reduce the part of the script (at the end)
to:
So the result is only if it's o mobile device or not:
And you can use this result as an switch for other questions / relevance equations.
Don't forget tho hide the question. Either by the attributes Display > Always hide this question, or by 'decommenting' the line
//$('#question{QID}').hide();
into
$('#question{QID}').hide();
simplest way:
A - decide which info is required
1.) create a new question (textarea)
2.) use the "Source" button in the Question editor
3.) copy and paste joffm's script (it gives you more information than mine) into the editor area
3) save the question an run it
You will see something like this:
Code:
OS: Windows 7 Browser: Chrome 66 (66.0.3359.170) Mobile: false Flash: no check Cookies: true Viewport width: 2691 Viewport heigth: 1612 Screen Size: 3072 x 1728 Full User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36
B - delete the output not necessary for you. E.g. if you only need the mobile flag, reduce the part of the script (at the end)
Code:
... ... $(document).ready(function() { // Hide this question (remove double slash below to hide) //$('#question{QID}').hide(); // Load the question $('#question{QID} textarea').val( 'OS: ' + jscd.os +' '+ jscd.osVersion + '\n' + 'Browser: ' + jscd.browser +' '+ jscd.browserMajorVersion + ' (' + jscd.browserVersion + ')\n' + 'Mobile: ' + jscd.mobile + '\n' + 'Flash: ' + jscd.flashVersion + '\n' + 'Cookies: ' + jscd.cookies + '\n' + 'Viewport width: ' + jscd.vieww + '\n' + 'Viewport heigth: ' + jscd.viewh + '\n' + 'Screen Size: ' + jscd.screen + '\n\n' + 'Full User Agent: ' + navigator.userAgent ); });
to:
Code:
... ... $(document).ready(function() { // Hide this question (remove double slash below to hide) //$('#question{QID}').hide(); // Load the question $('#question{QID} textarea').val( jscd.mobile; ); });
So the result is only if it's o mobile device or not:
Code:
false
Don't forget tho hide the question. Either by the attributes Display > Always hide this question, or by 'decommenting' the line
//$('#question{QID}').hide();
into
$('#question{QID}').hide();
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- orvil
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
5 years 11 months ago #168705
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Checking if a survey is opened via mobile device?
Hi Joffm,
thanks for this script. Gives a lot of useful information on top. Will try to extend it to get the dpi too
thanks for this script. Gives a lot of useful information on top. Will try to extend it to get the dpi too
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- orvil
- Offline
- Premium Member
Less
More
- Posts: 111
- Thank you received: 20
5 years 11 months ago #168706
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic Checking if a survey is opened via mobile device?
Hi DenisChenu,
thanks for the hint! I'm waiting desperately for some 3.x updates for the great plugins you've wrote.
P.S. And beside still for a solution for an update save em_core_helper.php
thanks for the hint! I'm waiting desperately for some 3.x updates for the great plugins you've wrote.
P.S. And beside still for a solution for an update save em_core_helper.php
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- Gustavo_Kremer
- Offline
- Junior Member
Less
More
- Posts: 26
- Thank you received: 0
4 years 11 months ago #184111
by Gustavo_Kremer
Replied by Gustavo_Kremer on topic Checking if a survey is opened via mobile device?
Hi. In previous posts Joffm's script is mentioned, but I'm not seeing it anywhere in the thread (just the last part). How/where can I find it?
Many thanks!!!
Many thanks!!!
The topic has been locked.
- Joffm
- Online
- LimeSurvey Community Team
Less
More
- Posts: 12922
- Thank you received: 3977
4 years 11 months ago #184115
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Checking if a survey is opened via mobile device?
Hi, Gustavo,
my post disappeared because somebody banned me for a few hours (probably by mistake).
But obviously all my posts are gone.
Joffm
my post disappeared because somebody banned me for a few hours (probably by mistake).
But obviously all my posts are gone.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- DenisChenu
- Away
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
4 years 11 months ago - 4 years 11 months ago #184117
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Checking if a survey is opened via mobile device?
Yes, it's MY mistake … i want to thank you, but click on bad button … Really sorry … really sorry :blush: :blush: :blush:
Issue reported : bugs.limesurvey.org/view.php?id=14860
Issue reported : bugs.limesurvey.org/view.php?id=14860
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 4 years 11 months ago by DenisChenu.
The topic has been locked.
- Gustavo_Kremer
- Offline
- Junior Member
Less
More
- Posts: 26
- Thank you received: 0
4 years 11 months ago #184135
by Gustavo_Kremer
Replied by Gustavo_Kremer on topic Checking if a survey is opened via mobile device?
Hey, now it's back! Many thanks!
The topic has been locked.