Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2018
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript for if Else HTML

    Iím trying to use javascript to display html conditinally.
    If condition a is met I want to display an iframe section. If the condition is not met I want to display the page I was going to show in an iframe as the whole page. Is there a way to use javascript to show conditional html?

  2. #2
    New to the CF scene
    Join Date
    Apr 2018
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <!DOCTYPE html>
    <html>
    <body>

    <script>
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
    document.write("Not Mobile");
    }
    else{
    document.write("Hello, world!");
    }
    </script>
    </body>
    </html>

  3. #3
    New to the CF scene
    Join Date
    Apr 2018
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Davidlphillips View Post
    <!DOCTYPE html>
    <html>
    <body>

    <script>
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
    document.write("Not Mobile");
    }
    else{
    document.write("Hello, world!");
    }
    </script>
    </body>
    </html>
    Not sure how to mark this as solution.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •