The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 5 of 5

Thread: MEDIA QUERIES to Load specific HTML file

Hybrid View

  1. #1

    MEDIA QUERIES to Load specific HTML file

    Hello. I'm looking for a short media query/JavaScript script that will tell the browser to load a specific html file depending on the device or the browser width. Any tutorials anyone can point me to? Thank you in advance.

    FS

  2. #2
    Do you want this URL to replace the entire document or just load some HTML into a small region of your page?

    Great, now even Kirupa is { facebooking | twittering }

  3. #3
    I want to an entire document. For example, if the a user is viewing the site on a desktop or on a device with a width beyond 550, I want the desktop.html to load. If the user is viewing the site on a smartphone like the ipHone, I want iphone.html to load. I know this code needs to be the first script that runs, so the user can be directed to the appropriate page depending on what they are viewing the site on. Thanks!

  4. #4
    Try using window.matchMedia to detect and window.location to redirect.
    Depending on the browsers you are targetting, you will need some kind of compatibily layer. http://caniuse.com/#search=matchmedia

  5. #5
    +1 to what gamera said!

    You can look at some alternative techniques to matchMedia I provide here: http://www.kirupa.com/html5/viewport...ument_size.htm

    Great, now even Kirupa is { facebooking | twittering }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012