• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Dave Anderson
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Err... umm... Hi Eric!
reply
    Bookmark Topic Watch Topic
  • New Topic