Server Side Include trouble in HTML document on Brackets - html

I have been trying to incorporate my navigation bar into each page of my website using a server side include. My goal is to be able to just change one file and each page would have the amendment. I have recently asked a question about this and got a solid response: <!--#include virtual="menu.cgi" --> or <!--#include file="footer.html" -->
This sounds like it works great but in my coding editor, brackets. It treats this as a comment and therefore does not work.

Server Side Includes, as their name suggests, are a feature of a web server.
They shouldn't "work" in a text editor. That is just a tool to let you edit the code. (And the syntax is designed to be the same as HTML comment syntax so that tools handling plain HTML will treat them as comments).
Test your code using a web server.

Related

ASP not running in .htm file in browser

I am attempting to run some asp code in a htm file however whenever I open the file it doesn't actually run the code but instead just displays the code without the '<%%>'. I've tried changing the file type to all sorts of things (.html, .asp, .aspx, .shtml) however none change anything and .asp doesn't even run (instead just displays the text as the the browser would when opening a text document).
I found some code on w3schools.com which is where I'm learning html however it doesn't work nor does the site mention any prerequisites for using asp code in an htm file.
The code:
<!DOCTYPE html>
<html>
<body>
<% response.write(request.querystring("fname")) %>
</body>
</html>
I have gone and ticked the ASP Windows features and whatever else related but that did nothing.
I am on a Windows 10, if that is relevant.
I am using opera (though I've tried opening in Window's Edge as well) and just opening via double-click or dragging into window. I am new to html in general so sorry for such a dumb question that may have already been answered before, I have searched a lot but after quite some time I decided to just ask.
I'm not sure what you are learning, but I think you might have come across Classic Asp. I'd recommend you download Visual Studio Community Version which you can find here
and instead try to learn ASP.NET.
However, if you want to launch your file you will need to use the local IIS. Simply go to START and in the search bar type IIS:
It should look like this:
On the left hand site, you will see SITES --> Right Click On it and point it to your Folder/File. Once it's there, then click on your SITE Folder in IIS and click on START which is on the right side with a red border. If it doesn't come up, click BROWSE *.443 which is right below it. It should launch.
If you are just starting, I'd suggest you download Visual Studio Code or ATOM and start creating simple .html files/website. It might be too overwhelming to go into ASP.NET or Classic before you become familiar with static .Html files.

Import HTML without using PHP?

Is there a way to import a block of HTML into a file without the use of something like PHP or Javascript? For my personal website, any time I make a small change to the content of my navbar, I have to go to all of my other pages and make that same change.
Do an internet search for "Server Side Includes for HTML"
Here's a good start:
http://en.wikipedia.org/wiki/Server_Side_Includes
Example:
<!--#include virtual="header.html" -->
No feature like the one you described is in the HTML spec, but if you don't have access to server configurations and the like, you can write your code in a language like HAML and compile it, which would accomplish what you described without any server-side work.

call single css menu in multiple html pages

I'm in the process of creating a website.
I have a menu bar which is common for all the pages. I want to call the HTML page which contains the menu bar from any page within my site.
Is there any syntax to include HTML files so that I can solve my issue.
If so how to do it?
You need to use php extension for you files instead of html and call your header with
<?php include_once('header.php'); ?>
where you want header to be displayed
If you are working on local machine install xampp or you will not be able to see your website because php is server side scripting language
** Answer from other questions **
You are describing server side includes.
Server Side Includes are useful for including a common piece of code throughout a site, such as a page header, a page footer and a navigation menu.
Example of usage:
<!--#include virtual="../quote.txt" -->
This will add the text of quote.txt to the page - if you add it to multiple pages, you can make your change in this one file and it will show on all pages in was included in.
Different web servers have different support and additional features for these, so you need to check the documentation for yours.
Many websites that need dynamic features (like fetching data from a database) will use some kind of server side scripting language for this kind of functionality - examples include PHP, Perl, ASP.NET, JSP and many more.

html link for mouse hover

I'm looking for something similar to the a html a tag title text but I want the text to come from a separate file.
For example
whatever
IF you do not have access to server side scripting, then you can have your javascript make an ajax request to the file. Javascritp can open files, but they have to be server readable.
Javascript cannot read from file.
But anyway that is not what you want. You most probably want the text to come from a file in the server, rather than a file from the client machine.
You need server side technologies (PHP, ASP, JSP/java...) for this.
UPDATE:
Ok. You don't have server side technologies. So this is not directly possible. But, first: how are yout HTML pages generated? Hand-coded or generated by some system (a CMS, for instance)?
If you are hand coding your HTML, you need the content of the "title" dynamically (from a file), then this is not possible. HTML or related technologies cannot "directly" read a file, and definitely not a file on the server.
If your HTML is generated by some sort of a generator, then possibly you can integrate this with that system itself.
I absolutely have no idea about the requirements, but is it possible to generate the HTML file based on your "configuration" file with the text everytime the text file changes.
BTW, how complex is your HTML?

Embedding HTML files in other HTML pages

I am new to HTML. I have an html page named "main.html" and i want to include another html page called "menu.html" in it. My main.html page doesn't include frames and it is designed using div tags. My site is hosted on linux based server The site I have to redesign is Java questions.
You want to look at Server Side Includes (SSI). This tutorial by Apache should get you up and running if that site is running on Apache.
There are plenty of Server Side ways of doing this, but all except SSI require the use of a language other than HTML.
If you're using IIS, you can check out Microsoft's writeup on Server Side Includes.
Check out server side includes.
You should use server-side includes.
i.e. in jsp you can use: <c:import url="/include/navigation.jsp" />, in php <?php include("/sidebar.php");?> and so on.
This is the good way to do what you need: include a navigation menu, or other parts common to all pages, without rewriting it in each page.
You can also do the same in other ways (with some javascript i.e.) but I doubt that you want to build a site called Java Questions without any server side language.
I think that PHP is the easiest way to do this. Most of the time you can just change your main.html file to main.php then add this php code where you want the menu bar:
<?php include('menu.html'); ?>
And that's it! You have to make sure that php is installed on your sever. Also this will ONLY work on a server. So if you are testing on your computer and using something like dreamweaver (or even a browser), you won't see anything until it's online.
You can make an ajax call in javascript if you want to avoid using the server.
In JQuery you would do:
<div id="putStuffHere">
</div>
<script>
$('#putStuffHere').load('myStuff.html');
</script>