-1

I found code on here some while ago. I'm trying to have my href link redirect based on the device viewing the page. This is what I originally found:

$(document).ready(function($){
    var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
    if (agentID) {
        $('#myLink').attr('href', 'http://example.com/useiOSapp.html');
    }else
     { $('#myLink').attr('href', 'http://example.com/flash-app-page.html');  }
});

But on this code, I'm getting the following error: Adjacent JSX elements must be wrapped in an enclosing tag (3:0)

Any ideas?

2 Answers2

1

This is a JSX error, and should be unrelated to your redirect if/else.

edward
  • 142
  • 1
  • 6
0

From your codepen (codepen.io/marcelduplessis/pen/Gzdryz), you're confusing a javascript file with a html file. You don't need to put your javascript inside <script> tags in a javascript file - you would do that in a html file. I'd suggest going back to basics on javascript.

andydavies
  • 3,081
  • 4
  • 29
  • 35