Connect with us

Hi, what are you looking for?

Technology

How to display content on page using query string in URL

Query String

Query string parameters are added to website URLs when using tracking URLs to track a visit from a particular source and campaign or passing correct values in the URL to display desired data and information.


In addition, they are also used in some systems CMS external files to display specific content on a page. With that in mind, we will be teaching you here at Coliseu Geek a simple and quick way to display content on a page using a query string in the URL! Check out!

URL - How to display content on page using query string in URL
 

<div id="content"></div> <script> // Get the value of the "content" parameter from the URL query string const urlParams = new URLSearchParams(window.location.search); const content = urlParams.get('content'); // Display the content on the page document.getElementById('content').innerHTML = content; </script>

Note that this script assumes the content parameter contains text plain. If you want to display the HTML content of the query string, you need to make sure to clean and escape the input to prevent XSS attacks.


Written By

My name is Juan de Souza, I'm 24 years old, I'm a businessman, investor, blogger, streamer and podcaster. I started my first business when I was 10 years old, using a dial-up connection in Brazil. Founded businesses like TFX, Coliseu Geek, among others.

Comments
Advertisement
Advertisement

See what we recommend about our Coliseu for you:

webcamwebcam

Technology

Exactly at the beginning of 2016, the director of the FBI, James Comey, was the subject of several controversies when he admitted that he uses stickers...

StorageStorage

Technology

Have you ever wondered how many storage units there are in computing? Believe if you can! Currently, there are more than 25 storage units and they...

Scalable Vector GraphicsScalable Vector Graphics

Technology

Scalable Vector Graphics – The internet has come a huge way since HTML5 became popular and people started looking at...

Tips

Do you know or have you heard of the term "Kernel"? Do you know the meaning? Rest assured, in this article you will understand everything!







Disclaimer: We prioritize producing completely impartial content and follow this definition to the letter. Never, under any circumstances, will you find articles and productions with an ideological or political bias on our website. We analyze and question any side or point of view, in order to bring our audience the highest quality and transparent content possible.

Copyright © 2024 Coliseu Geek - All rights reserved. "Coliseu Geek" is a product and property of the company TFX.