Javascript beginner trying to use WURFL

279 Views Asked by At

I'm trying to identify the users device using WURFL. I found this site: http://web.wurfl.io/#learnmore and just did as said in the description:

<!DOCTYPE html>
<html>
    <head>
        <title></title>
    </head>
    <body>
        <script type='text/javascript' src="http://wurfl.io/wurfl.js">
            console.log(WURFL);
            document.getElementById("output").innerHTML = WURFL.complete_device_name;
        </script>
        <div class="text" id="output" style="font-size: 3em;"></div>
    </body>
</html>

But as I open the file in Firefox/Chrome the console and page contains no content.

Thanks for helping!

PS: The Firefox console displays "The character encoding of my html document is not declared and might be displayed wrong in certain browsers." How can I declare my character encoding?

1

There are 1 best solutions below

1
Madara's Ghost On

That's now how to write inline scripts in HTML.

You want this:

<script src="...."></script>
<script>
  // Your code here
</script>

A script cannot have both an src= (which means that it's an external source) or text content (which means it's an inline script). You need two <script> elements.