• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Non-mobile device to appear as mobile device to a remote webpage

 
Dave Anderson
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose a webpage request is made made to a website, and that the called webpage can recognize if the request is from a mobile device.

Now suppose I have a javascript program that is NOT designed to run on a mobile device, but would like to call this website and request this webpage appearing as though it were a mobile device.

Right now if I just use location.href = url, I can retrieve the non-mobile webpage ok, but not the mobile page I want.

Does anyone know how to make a webpage request and set a flag or something else to make the webserver return the page designed for mobile devices?


 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The web site most likely looks at the HTTP User-Agent header. You can play around with that using the Develop -> User Agent menu in Safari, or any number of Firefox extensions.
 
Dave Anderson
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I am sure that if one can affect the User-Agent header then one can do this, since this is how webpages determine if a mobile device is calling.

I was hoping for something specific to Javascript to do this using 'location.href = url', but I assume this is a deadend from what you are saying.

Perhaps there is a way to do this using the XMLHttpRequest object.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript can not change the headers for user agent.

Spoof it with a plug-in as Bear suggested. There are plenty of them out there.

Eric
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Err... umm... Hi Eric!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic