Simply transfer HTML code into other HTML files [duplicate] - html

This question already has answers here:
Multiple webpages with common title and navigation bars
(4 answers)
Closed 2 years ago.
I would like to start a homepage for me. Every time I add a thing to index.html I have to add it to the links (in about.html etc.) as well.
How can I simplify that, that the new things of the index.html are automatically transferred directly into the other links (about.html etc.)?
Thanks for the help

The solution I used was to create a JS script that you would include in your HTML, that would add the HTML you want to the document :
let body = document.getElementsByTagName("body")[0];
body.insertAdjacentHTML("beforeend", "your html");
You could then put this script where you want to include the HTML.
I don't know if it's the best solution, but it works.

Right now, using vanilla HTML, there is no quick, easy, and simple way to do this. Using a backend framework like Django, this is easy, but that is really complicated and takes a while to learn!

Related

ID # reference without index.html [duplicate]

This question already has answers here:
Reference: mod_rewrite, URL rewriting and "pretty links" explained
(5 answers)
Closed 5 years ago.
long time lurker first time signup and poster.
quiet simple really
how do i reference from the navigation page/index.html#id to just page#id
- so i dont want it to show index.html
ie.
ww.page1.com/pasture#clover
i am currently using the codes below, and dont mind if i need to put in some other code. the pages will be in .php later on but for now in html.
I am using the below codes
Clover
from the navigation on the first page/all pages
<h3 id="clover">Clover</h3>
and this on the target page
What you want: Anchors (or Bookmarks)
Look here: https://www.w3schools.com/html/html_links.asp
So: Use Clover
Also: If you call the site as www.abc.de/index.html#123, then it will stay as it is - and give you www.abc.de/index.html#clover.
If you call the site as www.abc.de/#123, then it will also stay as it is - and give you www.abc.de/#clover.
Edit: I misunderstood the OP. I may edit this post later. Sorry.

Webpage practice [duplicate]

This question already has answers here:
Is there an HTML/CSS/JS editor that immediately shows changes? [closed]
(6 answers)
Closed 6 years ago.
I have been learning HTML + CSS via online courses like codeacademy and W3schools. I have a very simple grasp as to creating webpages and I want to play in a "sandbox" by creating pages and just messing with stuff.
I'm looking for somewhere I can type in my HTML and CSS and have it display on a webpage just like any other page I look at. I haven't been able to find anything quiet like that, other than the courses themselves. Is there even such a thing?
You could try JSFiddle
It accepts JS, HTML, CSS and renders it realtime...
You can download a coding software such as Brackets. Save your html file as index.html and your css as styles.css (per example) in the same folder.
Simply click on them in your computer's documents and it should work, opening in your default browser. You don't need an "online" tool for html/css.
Also check out this blog post for alternatives
I would highly recommend http://codepen.io. I find it the most user friendly of the bunch
I think JsFiddle would work for what you want. It also allows you to incorporate javascript as you begin to branch out. Plunker is also something I would recommend as it has a "live preview" where your page will automatically display as changes are made.
Get a free website from a site like 000webhost. Then, you can upload and edit code in real time on the server and view it on eg. http://example.freehost.com and you can view it real time. Also you could use software like notepad++ and edit your code before uploading it. Make sure your homepage is index.html

How does one change the language of an HTML page? [duplicate]

This question already has answers here:
How to specify language of website? (HTML?)
(3 answers)
Closed 2 years ago.
Specifically, I am writing in AMP HTML, if there would be any conflictions.
I would like to approach a pretty cool concept of being able to change the language of an HTML page I am working on, just by the click of a button, like so:
<button>Parlez-vous Français?</button>
I would like the person do be able to click a button that would specifically translate the page into French. But it would be cool to add some animation to it too, like maybe a fade-out/fade-in sort of thing.
How would I be able to approach this?
You can simply change it in the HTML tag itself
<html lang="fr">
...
</html>
considering you know that it's an html attribute. There are many ways you can change it. Storing the change can either be on database or session storage. Hope this helps

Change Code in multiple HTML files [duplicate]

This question already has answers here:
What are the new frames? [closed]
(3 answers)
Closed 8 years ago.
Is there a way I can change code in multiple static HTML files? I just added two new pages to the site, and the side bar containing links to all the pages need to be updated in all files. Is there a easy way to do it? Thank you very much.
Update: Also the side bar has an active row, which should be different in each file, is there a easy way to change that in each file as well?
notepad ++ allows you to search and replace and also has a reg-ex search and replace function you can use to replace all or replace via file extensions
The question you are asking has two good answers.
The first simple answer for your level of HTML knowledge would be to use a text-editors Find & Replace functionality to simply change identical pieces of code so all pages match. This would be the simplest answer for your question.
The larger answer would be to introduce you to the idea of a layout file. With this layout file(s) you could define your entire page layout, links, headers, etc. Then with each page you load you simply call the content you want to show inside the layout file. This is a high level concept and should ultimately be your goal to reduce issues like those which you stated in your question.
You can accomplish this with a variety of technologies such as PHP, ASP.Net, or Java EE development which are all very advanced stacks. The best starting point I would suggest is Server Side Includes. This will allow you to simply call the required layout text. While this solution is rather legacy; it might help you accomplish your task with grater efficiency.
Microsoft Visual Studio Express can find and replace in files.
But maybe it's time to refactor your pages and put the common information in a distinct file.

Menu from external file [duplicate]

This question already has answers here:
What are the new frames? [closed]
(3 answers)
Closed 9 years ago.
I am now making a webpage and need a bit of help. Its been some time since Ive done my last page a few years ago. Back then I remember it was quite popular to use frames, but these days, this is basically no longer used.
What I used to do is have a horizontal menu on the top as a frame, and underneath it the content frame.
Now, currently I have a webpage again, where I would like to place a horizontal menu on the top of the page.
The menu is written in pure CSS and HTML. The CSS is loaded from an external file, but the problem I now have is that the menu is basically a DIV element, which however I have to put into each page separately.
I was just wondering there must be a way of making this simpler and have it somehow inserted from an external file again - sorry maybe it sounds confusing, but basically I am looking for an alternative of the frames used in the past. Many pages have menus and I am sure they do it somehow, because if I make a change in the menu, I dont want to be making these changes on all the hundreds of pages.
I dont ask for any specific coding etc. I can google that myself if I dont know how to do it, but I just need a general recommendation how to solve this. Just to summarize, the menu is in HTML+CSS and the pages are mostly PHP, some of them HTML.
I'd think it would mostly depend on the framework. You could just have one page, and use AJAX to load the content of each page, or you could have several php pages, all of which call some function at the beginning to set up the header, or you could use a ASP.NET master page or whatever your framework uses.
If you're using PHP, then the easiest way would be :
<?php include('my_page.html'); ?>
Be carefull of the path to your html page