How to choose from different Hype index (desktop / ipad-mobile)

I have a "TIMELINE" project, for which I have created two distinct Hype documents:

  • "desktop" document (with mouse wheel)
  • "iPad / mobile" document (this document has two layouts, one for iPad and one for mobile)

There is a way to:

  • recall from the PC only the "TIMELINE" "desktop" document, and
  • recall from iPad and mobile only the “iPad / mobile” document of “TIMELINE”?

function isTouchDevice() {
  return (
    !!(typeof window !== 'undefined' &&
      ('ontouchstart' in window ||
        (window.DocumentTouch &&
          typeof document !== 'undefined' &&
          document instanceof window.DocumentTouch))) ||
    !!(typeof navigator !== 'undefined' &&
      (navigator.maxTouchPoints || navigator.msMaxTouchPoints))

//window.location.href = "";
//window.location.href = "";
alert('NOT mobile')

if i got you right :slight_smile: there'll be a thousand other solutions ... depends on your needs ... it's bveen a bit unclear :slight_smile:


1 Like

Hello @h_classen,
thanks for the suggestion :+1:

Do I need to insert this script in the HTML header of both Hype documents?

In the code, do I need to replace "window.DocumentTouch" with the name of my mobile file, for example "window.TimelineMobile"?

well it's a basic detectionsnippet which lets it up to you how to progress.

for example you could create a third htmlfile that includes the script and does a redirection ...
window.location.href = "path2yourMobileHTMLFile.html" or vise versa

1 Like

Since I can't find a solution, I thought about creating an ipad document with iPhone layout only (320px), thus eliminating the 2388x1668px layout.

At this point I would like the redirect index to say something like "up to 320px width: loads the iPhone index. Over 320px width: loads the Desktop index".

Is there any way to achieve this behavior?

Are you aware of Responsive Layouts that are able to change based on a breakpoint width? If so, I'd be curious why you want to avoid them?

Good morning @jonathan

simply because in the document that I have set, inexplicably, they do not work.

Despite having set up a document with two layouts, a custom layout of 2388x1668 px (breakpoint: 1024 px) and the preset iPhone layout of 320 px, on iPad horizontal I don't see the custom layout of 2388x1668 px as I would expect, but I see the layout iPhone.

In the HTML header of the double layout document I added the script for automatic adaptation to the browser:

function layoutRequest(hypeDocument, element, event) {
var hypeDocEl = document.getElementById(hypeDocument.documentId());
//returns [{name: xxx; height:xxx; width:xxx; breakpoint: xxx}, ...]
var _layouts = 
//current Layoutname
var layoutName = hypeDocument.currentLayoutName();
//get data for current Layout -> {name: xxx; height:xxx; width:xxx; breakpoint: xxx}
var res = null;
for (var i = 0; i < _layouts.length; i++) {
var Obj = _layouts[i];
if ( === layoutName) {
res = Obj;
if (res) {
var wWidth =  window.innerWidth ||  (window.document.documentElement.clientWidth || 
var baseLayoutWidth = res['width'];
var scaleFactor = (wWidth/baseLayoutWidth); = 'absolute'; = "left top"; = "left top"; = "left top"; = "scaleX(" + scaleFactor +  ") scaleY(" + scaleFactor + ")"; = "scaleX(" + scaleFactor +  ") scaleY(" + scaleFactor + 
")"; = "scaleX(" + scaleFactor +  ") scaleY(" + scaleFactor + ")";
return false
if ("HYPE_eventListeners" in window === false) {
window.HYPE_eventListeners = Array();
"type": "HypeLayoutRequest",
"callback": layoutRequest

to make sure that the custom layout 2388x1668 px would be shown adapted on the iPad device.

the script above does not return any layout to show, but scales the actual layout proportionally regarding a windowwidth ... so it does not help distinguishing between two layouts ... just to clearify.


it'd would be good practice to offer a link and/or hypefile.

this is clear to me. I specified that I used this script in the html header of the document to understand if it could conflict with the redirect index script.

The solution I would prefer would be to have the redirect index say: "check the width of the scene (or page, or screen ...) if it is less than or equal to 320 px, load the iPhone index, vice versa, load the Desktop index ".

I'm trying to write it (in the dark, because I don't know anything about Javascript code):

<!DOCTYPE html>

function checkScreenWidth() {
	if ($(window).width() ≤ 320) {
	window.location.href = "tec-500k-iphone.html";

	else {
	window.location.href = "tec-500k-desktop.html";


Any corrections or suggestions are of great help.

Hype's got a functionality mentioned by jonathan to do just this... out of the box.

please provide a samplefile and someone may be able to help ...