Advertisement
JustMinecraftPlayer

JS Get URL Query

May 21st, 2022
811
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>JS Get URL Query</title>
  8. </head>
  9. <body>
  10.     <script>
  11.         function getQuery(obj){
  12.             let lhs = location.href.split("/")
  13.             lhs = lhs[lhs.length-1].split("?")[1]
  14.  
  15.             return lhs
  16.         }
  17.  
  18.         /*
  19.             Example
  20.         */
  21.  
  22.         document.write("    <style>h1{font-weight:bolder;font-family:sans-serif;background-color:#FFFFFF;border-style:solid;border-width:.3rem;border-color:#000000;width:auto;height:auto;border-radius:.25rem}em{color:rgb(85, 85, 85)}</style><h1>The <em>query</em> of this page is \"" + getQuery() + "\"</h1>")
  23.     </script>
  24. </body>
  25. </html>
Advertisement
RAW Paste Data Copied
Advertisement