Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isMobileDevice() {
- // Check for mobile-specific user agent keywords
- const mobileKeywords = ['Mobi', 'Android', 'iPhone', 'iPad', 'Windows Phone'];
- const userAgent = navigator.userAgent;
- // Check if any mobile keywords exist in the user agent string
- return mobileKeywords.some(keyword => userAgent.includes(keyword));
- }
- // Check if Storyline's player object is available
- if (window.hasOwnProperty('GetPlayer')) {
- // Get the Storyline player object
- const player = window.GetPlayer();
- // Check if the course is being viewed on a mobile device
- const mobileView = isMobileDevice();
- // Set the 'mobileView' variable in Storyline to indicate if it's a mobile device
- player.SetVar('mobileView', mobileView);
- }
- /*Please ensure you have a True/False variable in Storyline named mobileView*/
Advertisement
Add Comment
Please, Sign In to add comment