0

I am implementing javascript in birt to check the os of the machine as I am making a responsive report.

Here is my javascript

if(navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)){

var a = document.getElementsByTagName('svg');
    var i =0;
    for (i = 0;i< a.length;i++) 
    {
        a[i].style.width = '384px';
    }

    a = document.getElementsByTagName('embed');
     i =0;
    for (i = 0;i< a.length;i++) 
    {
        a[i].width = '384px';
        a[i].initialWidth = '384px';
    }
}

It gives me following error when I load it on the browser

ReferenceError: "navigator" is not defined. (/report/method[@name="beforeRender"]#1)

Mr x
  • 828
  • 1
  • 8
  • 25

1 Answers1

0

navigator is a property of the window object in a web browser. You only have access to it in a javascript file running in a web browser.

just.another.programmer
  • 8,579
  • 8
  • 51
  • 90