-1

I want to use a banner but when you open it with you mobile device the mobile banner should show up. Because viewport things. I have this code, but nothing happens. Can someone help me?

   <script type="text/javascript">
      <!--
      if (screen.width <= 800) {
        document.write = "<div align='center'><a href='http://www.fifacoin.com/?aff=53549'><img class='img-responsive' src='http://www.fifacoin.com/fifacoin/img/200X200.gif'>"
      }
      else {
          document.write = "<div align='center'><a href='http://www.fifacoin.com/?aff=53549'><img class='img-responsive' src='http://www.fifacoin.com/fifacoin/img/728X90.gif'></a></div>"
      }
      //-->
    </script>
halfer
  • 19,824
  • 17
  • 99
  • 186
Julan
  • 67
  • 1
  • 5
  • You should use media queries instead. – SLaks Dec 27 '15 at 15:17
  • As @SLaks points out - media queries in CSS were made for this - they provide a much cleaner solution than javascript which might not be enabled... but try using `parseFloat( screen.availWidth )` instead – Professor Abronsius Dec 27 '15 at 15:20
  • By the way, you posted a similar question here http://stackoverflow.com/q/34475651/ where I gave you answer for it http://stackoverflow.com/a/34476103/1415724 - Did I write all that for nothing here?? I believe you used part of my code to write whatever you're trying to do here. – Funk Forty Niner Dec 27 '15 at 15:40
  • I closed this question as an exact duplicate, because you are attempting to do the same thing here. – Funk Forty Niner Dec 27 '15 at 15:42

1 Answers1

0

the right syntaxe is document.write( "string" ); not document.write = "string" ;

To Read

VSnake
  • 121
  • 4