0

I want to redirect the user to a different page once the user has successfully identified the marker, is it possible to achieve this in AR.js

Rasheen Ruwisha
  • 135
  • 3
  • 10

2 Answers2

0

try this. Give your <a-marker> id like <a-marker id="marker" ...>

<script>
//using jQuery
var marker = document.querySelector("#marker");
marker.addEventListener("markerFound", function (evt) {
    //marker found
    //do stuff
});

marker.addEventListener("markerLost", function (evt) {
    //marker lost
    //do stuff
});
</script>
jef
  • 536
  • 1
  • 4
  • 14
0

Try this redirect to a different page <a-marker markerhandler ... >

<script>
AFRAME.registerComponent('markerhandler', {
    init: function () {
      this.el.sceneEl.addEventListener('markerFound', () => {
        // redirect to custom URL e.g. google.com
        window.location = 'https://www.google.com/';
      })
    }
  });
</script>