1

I want to use an iFrame to demo a mobile device. the thing is that the site I want to demo is http://m.domin.com/ and available only on true mobile device.

Is there any way to force the iFrame to be fake mobile device?

Thanks, Mosh

Mosh
  • 101
  • 2
  • 9

1 Answers1

0

Not quite sure I understand the question, or what you are trying to do here, so I'll try to answer as best I can.

Why are you creating a mobile specific site? With the state of HTML5 today, there is literally no need for creating a mobile specific site. To test simply open up Google Chrome, open up dev tools, and change your device to an number of mobile devices they let you test virtually.

Alternatively you can use user-agent-switcher if that's your thing. To do this in an iframe you would edit the user.agent for the iframe like so:

navigator.__defineGetter__('userAgent', function(){
    return 'foo' // customized user agent
});

navigator.userAgent; // 'foo'

It's apparently pretty finicky in some browsers though according to this previous related answer.

Community
  • 1
  • 1
  • 1
    Thanks for reply, I know the Google chrome tools to see mobile sites. What I'm trying to do is to create a preview frame for lot of website. The frame should show a preview how the should loom on mobile – Mosh Feb 22 '16 at 18:10
  • @Mosh Oh I see now. In that case you'll still need to spoof the user.agent, but instead you will do so in the iframe. I'll edit my answer to reflect this. – TylerCompiler Feb 22 '16 at 18:31
  • 1
    Oh nice! Can you give example of how to do so? :) – Mosh Feb 22 '16 at 18:33
  • 1
    Ok, will try that! Thank you very much – Mosh Feb 22 '16 at 18:45