iframe

Using <iframe> to embed external content on GitHub Pages can be tricky because many websites, including FlightAware, have security measures that prevent their content from being embedded on other sites. This is often done using HTTP headers like X-Frame-Options and Content-Security-Policy which restrict where the content can be displayed.

Here are a few alternatives you might consider:

  1. Using an API: Some services provide APIs that allow you to fetch data and display it on your site. FlightAware has an API that you can use to get flight tracking data. You could then use JavaScript to display this data on your GitHub Pages site.

  2. Link to the Page: If embedding isn’t crucial, you can simply link to the flight tracker page. This doesn’t provide the same seamless experience, but it’s a straightforward solution.

  3. Use a Different Service: Some flight tracking services might allow embedding. You could look for alternatives that provide embed codes.

Here’s a brief example of how you might use FlightAware’s API to fetch and display flight data:

Step 1: Sign Up for API Access

First, you need to sign up for access to the FlightAware API. You can do this on their API sign-up page.

Step 2: Fetch Data Using JavaScript

Once you have API access, you can use JavaScript to fetch and display the data. Here’s an example using fetch to call the API:

<!DOCTYPE html>
<html>
<head>
    <title>Flight Tracker</title>
    <style>
        #flightInfo {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
    </style>
</head>
<body>
    <div id="flightInfo">
        <h1>Flight BEL455</h1>
        <pre id="data"></pre>
    </div>

    <script>
        async function fetchFlightData() {
            const username = 'your_flightaware_username';
            const apiKey = 'your_flightaware_api_key';
            const response = await fetch('https://flightxml.flightaware.com/json/FlightXML2/InFlightInfo', {
                headers: {
                    'Authorization': 'Basic ' + btoa(username + ':' + apiKey)
                }
            });
            const data = await response.json();
            document.getElementById('data').innerText = JSON.stringify(data, null, 2);
        }

        fetchFlightData();
    </script>
</body>
</html>

Step 3: Host on GitHub Pages

Save this HTML file in your GitHub repository, and GitHub Pages will serve it.

Notes

Using an API will provide a more integrated experience and allow you to customize the data presentation as you see fit.