screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>URL Check</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState, useEffect } = React; function App() { const [protocolMessage, setProtocolMessage] = useState(''); useEffect(() => { if (window.location.protocol.startsWith("https")) { setProtocolMessage("The current URL is secure (HTTPS)"); } else if (window.location.protocol.startsWith("http")) { setProtocolMessage("The current URL is not secure (HTTP)"); } else { setProtocolMessage("The current URL uses an unknown protocol"); } }, []); return ( <div className="container"> <h3 className="header">React Js Check Whether Url Starts with https or http</h3> <p className="message">{protocolMessage}</p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> * { box-sizing: border-box; } .container { margin: 0 auto; width: 600px; text-align: center; background: #fff; border-radius: 5px; padding: 20px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); } /* Styles for the header */ .header { font-size: 24px; color: #333; text-align: center; margin-bottom: 20px; } /* Styles for the message */ .message { font-size: 18px; color: #666; text-align: center; } </style> </body> </html>