denehyg / reveal.js-menu

Slide out menu for reveal.js
https://denehyg.github.io/reveal.js-menu
MIT License
281 stars 76 forks source link

External links in iOS App mode #12

Closed jaxne closed 8 years ago

jaxne commented 8 years ago

We are using the reveal.js presentation with the reveal.js-menu as an HTML5 mobile app presentation in the chromeless safari App Mode. So far it is working great!

external link

Per the tutorial, I have "link.html" file with the two list item links for Resources in the above screenshot example. The calculator link should open a a new webpage we have in within the same "app mode" view window. By default iOS opens any links as a new tab in mobile safari vs. staying in App Mode. It doesn't matter if you remove the target="_blank", iOS will still open mobile safari in a new tab. I found one fix which is to write the link tag like the following using an in-line javascript call to change location.

<li class="slide-menu-item"><a href="javascript:this.location = '/calculator/'">Economic Calculator (beta)</a></li>

This does work on the iPad view and loads the page within App Mode View. However, we do have some folks using this in a regular browser and this call doesn't work. Wondering if anyone knows of a way to modify the Custom Menu Panels XMLHttpRequest code (line 442 of menu.js) to open the URL via a javascript location call vs. how it does it now.

A side note: Chrome inspector shows that the xhr.open( 'GET', element.src, false ); has been depricated not sure how crucial that is, but thought I'd mention it.

line 466 of menu.js xmlhttps-note

I realize this might not be considered a bug for typical browser use, but I thought it could help others who end up using Reveal.js as an HTML5 app presentation and want to link to other pages and maintain the app mode view. Thanks.

jaxne commented 8 years ago

I utilized a simple Javascript function to fix this issue. I added the following JavaScript function below the Reveal.initialize script on the main reveal presenation html file.

//Open Links in App Mode function navigator_Go(url) { window.location.assign(url); // This technique is almost exactly the same as a full <a> page refresh, but it prevents Mobile Safari from jumping out of full-screen mode };

Then for the the link you want to stay in "App Mode" set the href to call the javascript funtion with the URL... example below:

<li class="slide-menu-item"><a href="javascript:navigator_Go('http://example.com/link/');">External link to open in iOS app mode.</a></li>

Hope this helps anyone who is using Reveal.js in this manner. Many thanks to Greg Denehy for this Menu add-on!