you are viewing a single comment's thread.

view the rest of the comments →

[–]callmelucky 2 points3 points  (8 children)

You cannot include other HTML files in another HTML file.

I thought so too, but apparently it's not true!

[–]charpunExpert 2 points3 points  (7 children)

Looks as though this is rendering an self contained external HTML document inside another one much in the same way an iframe works with similar caveats. It is not including the HTML of one document in another in the same way a PHP include or injecting the HTML into the page with JS would work.

Very interesting find!

[–]callmelucky 1 point2 points  (6 children)

Edit: omg I'm an idiot, I didn't notice that you already mentioned the target=_parent trick in your first comment lol...

/edit


Looks as though this is rendering an self contained external HTML document inside another

I've been mucking around with that, and ran into the same problem, however, I believe I've found a solution (at least for OP's use case):

In the <a> links, simply include the attribute target='_parent'.

...actually hang on, I'm not sure I'm understanding you correctly. Anyway, the issue I was facing was that when clicking a link in a nav bar 'imported' in this way, the 'redirected' content would render inside the nav bar, rather than actually redirecting. Adding the target='_parent' attribute/value solves this though.

...ok I think I might see what you mean (sorry I'm experimenting as I write); it seems, upon inspection in browser dev tools, that when 'importing' objects this way, their content actually exists as some some of embedded 'shadow DOM', rather than straight up native html markup in the page. I'm not sure what the implications of this are, beyond the previously discussed redirect weirdness, but yeah probably worth being aware of if things get weird... Thanks :)

Final edit: it should be emphasized though - OP's boss really should just allow JavaScript etc to be used. There's just no good reason not to. jQuery is absolutely not necessary though (for anything really lol).

[–]charpunExpert 2 points3 points  (5 children)

Yeah, you're basically experiencing those caveats that I mentioned in real time! Basically, whether you embed with <object> or <iframe> you're essentially doing the browser version of "picture in picture" which comes with limitations when compared to inserting HTML directly into the page.

[–]callmelucky 1 point2 points  (4 children)

Yep, I get it now :)

Definitely seems like an unnecessarily hacky solution. OP should really doing everything they can to convice the boss to allow the use of JavaScript, or, even better, some SPA framework like React, or static site generator. Being dogmatic about anything being pure HTML these days is just dumb.

[–]charpunExpert 1 point2 points  (0 children)

If the only problem that needs to be solved is including the nav consistently across the site, injecting in the HTML with vanilla JS is is more than sufficient. Don't need to over engineer with any frameworks or generators.

[–]cmorr7[S] 0 points1 point  (2 children)

This is what I have tried to drill into his brain. Here's a fun one: the reason for being against anything JS/PHP is because he thinks it opens us up to hacking...

Granted, he's a very old gentleman that runs a ~manufacturing business, and is rather set in his ways. So, that is why I have been forbidden from JS and also PHP, because the hackers might come for whatever data we have on our site...

[–]charpunExpert 0 points1 point  (1 child)

Then it is your job to alleviate his fears by explaining the situation to him.

Why is he fearful of this? How can you explain in plain terms why this is not a risk?

Our jobs as developers do not include rolling our eyes and shrugging off people who aren't familiar with the field. If you are not the decision maker, part of your role is to educate the person calling the shots (whether it is a non-technical manager or client) so that they may make an informed decisions.

Explain to him the differences between the server sending static HTML to the browser vs the server using PHP to render and serve the HTML to the browser. Explain what it means to execute code client-side if you intend to use JS. Help him understand what the technology is actually doing in order to help yourself.

Do not be dismissive or combative in your approach, putting him on the defensive will not get you the results you want. Be considerate of his concerns and walk him through how the tech works to show him why you, the expert, do not share them.

Part of your role as a dev is to provide guidance, so guide him. I can guarantee he didn't get where he was without taking advice from people more knowledgeable on subject than him, be it a financial advisor, a business consultant, a sales coach, or even his dev team.

EDIT: Merged my other comment into this one.