SunOne Webserver HTML Includes - html

I'm running a large site, one that has a nav bar at the top. Rather than change the 100+ html files each time we want to change one of the buttons in the top nav, we want to switch the navbar to be displayed using an include of some kind. I want these includes to work on both Firefox and IE, and I don't want to have to change the extensions of each file either.
So far I've tried:
Javascript read file - This works fine on firefox, but IE has file reading blocked it seems.
HTML include - So far only works if we change the extension to shtml
PHP include - I know you can set up apache servers to run php scripts within html, but I don't know how to make this happen in SunOne.
iframes - I had to block iframes in order to comply with security standards.
I'm more than open to suggestions I haven't considered, or ways to make the above attempts work. Any ideas?

Eureka! I've found it!
So rather than include the html, why not just include the javascript and css? Every page will include a .js and .css file. The css can set the image src, and in each image I can use "onclick" to tell it to execute a function in the .js file with a simple window.location. Voila! Two quick changes will change the whole site!
Thanks to Mr. Lister for the CSS idea. That set me on the path.

Related

html changes won't show up in browser

I'm working on an assignment for a class where our teacher has given us a webpage built out with html and css. We are eventually supposed to create some animations with gsap, but first need to make our own edits to the webpage itself. I am using vscode and when I edit any of the html, the changes show up in my index.html, but not in the browser. Any idea why this is?
try to right click your browser and check in the sources to make sure it really saved your changes.
Try to use live server on VS Code and then whenever you save it will show up on the page.
-> https://techstacker.com/local-live-server-vscode/
Make sure you save the file and reload the page in the browser

HTML won't link up to CSS when I open it again

My problem is that I linked the CSS correctly when I created my HTML file, but then when I try to edit the CSS the other day, it just didn't update my HTML file and I did save it of course. One way I can get around this is by deleting the CSS in my htdocs and creating a new stylesheet with the exact same contents then linking the new one to my HTML. Can you guys tell me why is this happening and how can I prevent this from happening again?
I think that the problem is with cache. You can try running the site in an incognito/private window of your browser.
You can also inspect the page and see if the new styles are loaded. You can also try Empty Cache and Hard Reload option when you right click the reload button on chrome browser while inspecting.
one way you can prevent it is by doing all your css in the actual html file like so
<head><style></style></head>

Github pages not showing images inside my div

I created a new repo and uploaded all the files but the images in my div id="Container" inside my index files are not showing up. https://github.com/hkhan194/tres-chic/tree/gh-pages
I looked into all other questions regarding this matter and tried them but still no image showing.
#Hkhan I have tried the link in IE and Google Chrome,
In IE:
Your website is working fine, the images are getting displayed.
In Google Chrome:
The images are not getting displayed and when i checked the console ,I am getting this error
Error:
Mixed Content: The page at 'https://hkhan194.github.io/tres-chic/' was loaded over HTTPS, but requested an insecure script 'http://cdn.jsdelivr.net/jquery.mixitup/latest/jquery.mixitup.min.js'. This request has been blocked; the content must be served over HTTPS.
Solution:
It seems that Google chrome is not allowing acceptance of the script from the url you have mentioned for the JS.
So the "mixItUp is not a function" error is getting thrown since the mixItUp function is from the former JS file.
So you could save that javascript file as "jquery.mixitup.min.js" in your github in a specific path and then include the javascript in the tag in your index file as shown below,
<script src="Your path/jquery.mixitup.min.js"></script>
First off, this isn't really a GitHub pages question. GitHub pages simply hosts your files. This is really a question about the HTML.
Secondly, you'll have much better luck if you post a MCVE. In your case this would be a smaller test page that only displays a single image.
That being said, I recommend going to the resulting HTML file: https://hkhan194.github.io/tres-chic/
Right-click anywhere in that page, and then go to "Inspect Element". That will open up a window that lets you explore the page elements, see any errors you're getting, and see what's going on over the network. I'm using Chrome, but every browser should have something very similar.
On the Network tab, notice that some of your image files aren't being found. These seem to be the result of misspellings: JPG or jpeg instead of jpg, that kind of thing.
Then on the Elements tab, find your products grid. Notice that its height is 0, which doesn't seem right. Then go into the div class="mix category-*" tags and notice that they all have a display of none!
The problem is that your CSS is setting #Container .mix to display:none, which is going to prevent them from being shown.
Please try to get into the habit of exploring your page using this window, and try to understand the difference between what GitHub Pages is doing and what your HTML is doing. If you have further questions, please try to narrow your problem down to a smaller example page. Good luck.

Why does my CSS continue to search for code in .less files?

I'm working on an application and styling it right now, however occasionally when I save my style.css file (my temporary change stylesheet before changing it to LESS) I get some messed up elements that were fine before I reuploaded. I made no changes to those elements and I'm 100% sure it's not my CSS, it's also not my browser cache as I've cleared it and reloaded the page with the same issue. I've also added
?v=1.0.1
onto the end of my link to the stylesheet to trick the browser into believing it's a new one. (Learned that trick on StackOverflow to use with favicons, will give credit when I find where I got it)
It tries to search for the CSS in .LESS files that are non-existent on the web server. Could it be a problem with my bootstrap.css.map file being on the server?
EDIT: Another thing I can't seem to figure out, is why the CSS actually shows up under the LESS file reference?
I found my problem, it turns out I was using the wrong media attribute. For some unknown stupid reason I had set the style.css file to only display for print.. I just removed the entire media attribute to be displayed on all types and it works like a charm.

Paths relative to the file location and NOT the url

**** EDIT: SOLVED HERE Relative paths from file for img, a and header ****
Somewhat new to web design.
I just finished creating a dynamic site. It can read domain/category, domain/category/this-article-about-x, all redirecting to domain/index.php and working well.
However, I quickly learned that whenever I used a relative path such as ./include, the relative path was taking in account the current URL, and not the actual url where the php file is at.
I have 2 questions that I couldn't answer when browsing the internet for a long time:
1) If domain/index.php is trying to show an image with ./thumbnails/science/image.jpg, it won't work if the actual url is domain/category/, but it WILL work if its just domain/category(no slash at the end). Why this inconsistency? The HTML code is showing the src to the image is the same on both cases.
2) My header has a dropdown menu with categories. Once its submitted, it will call itself (header.php), see which category the user chose and redirect to domain/category. All works well. You can then rechange the dropdown menu to another category and everything loads again. But again, if you access directly domain/cateory/ (with the slash at the end), the CSS won't load, the images won't load as said on question 1, and submitting the form will cause a problem because it will look for header.php on domain/category/, and not just on domain where the header.php file actually is.
I have successfully used dirname(FILE) to make sure my includes all work (as far as my testing has gone, no errors). But I could not use dirname(FILE) to generate links or images 'img src=' that will always point to the images regardless of the URL.
On localhost, the HTML is coming as img src=c:\path\htdocs\thumbnails\img, which is right, but the image does not display anyway. Same with the 'a href' links. Trying to create links with dirname(FILE) created links on localhost as c:\correctpath, but clicking on them did absolutely nothing. Also, using header with dirname(FILE) to handle the redirection from the dropdown menu caused it to cease working as well (but if I used ./ . dropDownMenuValue, it would again correctly change the url to domain/categoryChosen)
How can I use a consistent method for relative urls that allow me to work on localhost and then upload to my web host without the need make changes to the files, AND that works with dynamic websites that have pretty name urls through htaccess?
Thank you,
This is all very puzzling for me how getting a relative path from the current file path is being so hard and generating so many different issues, and why only include statements seem to work well with dirname(FILE)
Edit: http://board.phpbuilder.com/showthread.php?10374336-RESOLVED-mod_rewrite-for-SEO-Friendly-URLs-and-relative-path-issue-fixes
I've found this on other sites, but it requires you to change the base everytime you want to go from localhost to the web. I'm trying to avoid that. Clearly there has to be a simple way to do something so basic. I can't believe google and everybody else are changing paths when they are ready to make something live.
You should just always use absolute paths for public files like media. If you don't want to do that for some reason or your site is just too involved at this point you'll have to create rewrite rules for the other file types so they can also be included from the correct path.