+ 2
Can u create a multipage website on sololearn or u can only create single page websites
9 Réponses
+ 2
You can make multi-page website on sololearn
+ 2
Thanks Kwaw Essien I was actually going to add more pages ( refer to my <!-- comments --> inside the code )
+ 1
Could u give me an example
with a code
+ 1
Wow thats a lot of code
Thanks 😄
0
The SoloLearn code editor only supports a single HTML file and a single CSS file and a single JS file. But that doesn't mean you cannot create multiple web pages. How it works is:
You have components in your HTML. head, body, div tags, p tags, etc. The contents of those can be changed programmatically. So while you only have those three source files, you can dynamically generate what is shown on the screen. That makes multiple pages possible. This is typically called a single-page application.
When you create an HTML page, create DIV tags to hold the dynamic content. That could be the menu, the title, the body, or elements within the body. Then use JavaScript, attached to buttons, to swap out that content. You see this on many web pages these days.
Frameworks like REACT use this technique to build full scale applications that may only have five "real" pages but generate endless viewable pages which are dynamically generated.
The HTML can be very basic. All the work is done in JavaScript.
In a real-world environment, you can have multiple HTML files and each can have it's own dynamic content. In SoloLearn, you are stuck with a single HTML file. But you can accomplish a lot with that.
Here is a sample:
https://www.sololearn.com/en/compiler-playground/Ww74ViL7mMTl
This shows that new content is created whenever a button is clicked. It's very basic so hopefully you can understand how it works.
0
Thanks again😄
0
Ok👍
0
Oo