Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
zaxos
- Posts: 222
- Joined: Thu May 23, 2013 11:15 pm
Post
by zaxos » Mon Dec 15, 2014 11:04 pm
Code: Select all
local tBrowserId
on mouseUp
closeBrowsers
set the httpHeaders to "Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>"
put revBrowserOpen(the windowId of this stack, "http://www.youtube.com") into tBrowserId
if tBrowserId is not an integer then
answer "Failed to open browser"
end if
revbrowserSet tBrowserId, "rect" , the rect of grc "tBrowser"
end mouseUp
on closeBrowsers
local tInstances, tInstance
put revBrowserInstances() into tInstances
repeat for each item tInstance in tInstances
revBrowserClose tInstance
end repeat
end closeBrowsers
any particular reason this dosent work? is there a way to change the headers to get the mobile version of the websites?
EDIT: • useragent - MAC ONLY. If propertyValue is non-empty the browser instance uses that string instead of the default for the User-Agent header transmitted to the web server. If propertyValue is empty the browser instance uses the default user agent string (which is determined by the browser the URL that is being requested).
Found this but it says MAC ONLY...
Knowledge is meant to be shared.
-
LCNeil
- Livecode Staff Member

- Posts: 1223
- Joined: Wed Oct 03, 2012 4:07 pm
Post
by LCNeil » Thu Dec 18, 2014 5:05 pm
Hi zaxos,
I would recommend using the new CEF browser as this is the new browsers implementation in LiveCode. I have also adjusted your header to reflect an actual device and then set this via revBrowserSet. This results in the correct mobile page showing. The Mac only useragent clause seem to be due to out of date documentation as I tried the script and it works on both windows and mac. Could you try the following script to see if it works for you.
Code: Select all
put revBrowserOpencef(the windowId of this stack) into tBrowserId
if tBrowserId is not an integer then
answer "Failed to open browser"
end if
revbrowserSet tBrowserId, "rect" , the rect of grc "tBrowser"
revBrowserSet tBrowserID, "useragent", "Mozilla/5.0 ;iPhone; CPU iPhone OS 7_1_2 like Mac OS X; AppleWebKit/537.51.2 ;KHTML, like Gecko; Version/7.0 Mobile/11D257 Safari/9537.53"
revBrowserSet tBrowserID, "url", "http://www.youtube.com"
Kind Regards,
Neil Roger
--
LiveCode Support Team ~
http://www.livecode.com
--
-
zaxos
- Posts: 222
- Joined: Thu May 23, 2013 11:15 pm
Post
by zaxos » Fri Dec 19, 2014 5:00 am
Hey there runrevneil, thank you for your time answering, your code worked as expected and the browser opened mobile version of youtube, only thing is that no videos could be played, while on desktop version of youtube videos are working well. I also get this in debug.log
after just a little searching i found out that target-densitydpi is no longer used by chrome. is this the case? if it is is there a way to overcome it?
Thank you for your time.
Knowledge is meant to be shared.
-
zaxos
- Posts: 222
- Joined: Thu May 23, 2013 11:15 pm
Post
by zaxos » Fri Dec 19, 2014 5:08 am
using different user agents gives different results by the way, on some you cant even click the video, on others you click and video stays blank, none of them worked tho.
Knowledge is meant to be shared.