Upload a code from one page to another

Lord Regno

Active Member
Reaction score
19
This code are a menu code that link to other sides and I want it to be upload in the "main" pages, if its possible.

Code:
<div id="menycontainer"><ul>

<li><a class="meny" href="../Page/default.html">
<div class="roundtop">
<div class="r1"></div>
<div class="r2"></div>
<div class="r3"></div>
<div class="r4"></div>
</div>
<span class="menycontent"><strong>Page 1</strong></span></a>
</li>

<li><a class="meny" href="../Page/page2.html">
<div class="roundtop">
<div class="r1"></div>
<div class="r2"></div>
<div class="r3"></div>
<div class="r4"></div>
</div>
<span class="menycontent"><strong>Page 2</strong></span></a>
</li>

<li><a class="meny" href="../Page/page3.html" id="current">
<div class="roundtop">
<div class="r1"></div>
<div class="r2"></div>
<div class="r3"></div>
<div class="r4"></div>
</div>
<span class="menycontent"><strong>Page 3</strong></span></a>
</li>

</ul></div>

Main pages code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> [SIZE="3"]<- Are this right links to a CSS side?[/SIZE]

<head>
<title>Menu Page</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="Css/layout.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="centrering">
<div class="rund">
 <div class="rundtopp">
   <div class="rundh_r1"></div>
   <div class="rundh_r2"></div>
   <div class="rundh_r3"></div>
   <div class="rundh_r4"></div>
   <div class="rundh_r5"></div>
 </div>
 </div>

<div id="kolumncontainer">
<div id="sidhuvud"><div class="pic"></div></div>

<link href="meny.html" rel="stylesheet" type="text/html" />  <- Here I want the code to be uploaded if its possible

<div id="kolumn">

Text...

</div></div>
</body>
</html>

The last page is abridged.

Ps. Sorry for my bad English. But I hope that you understand what I mean.
 

UndeadDragon

Super Moderator
Reaction score
447
If your server lets you use PHP, you can use:

PHP:
<?php include("menu.html") ?>
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
If your server lets you use PHP, you can use:

PHP:
<?php include("menu.html") ?>

Could also use a small AJAX script to load it. Might actually turn out better since it can load the content after the main page is rendered.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Could also use a small AJAX script to load it. Might actually turn out better since it can load the content after the main page is rendered.

Hell no :eek:
AJAX is not intended for such a thing.

You can't decently load anything that went between the <head>-tags, you're only serving your content to people with javascript, it doesn't like cross-domain requests and it will cause the browser to 'shift' lay-out as soon as the XHttpRequest comes in.

PHP includes are the way to go here.

If your host doesn't allow that, I suggest you start paying for hosting, you find a free host that does offer php support or you install your own little (X/M/)LAMP.
 

UndeadDragon

Super Moderator
Reaction score
447
Then again, Minecraft works :)

QFT :p

AJAX may work in this situation, but it's just no. Not when there are other, better alternatives.
 

tooltiperror

Super Moderator
Reaction score
231
You people with your fancy codes and server side scripting.

Try copy paste. I imagine if you're not using PHP your manual scripting each page anyways.
 

JerseyFoo

1/g = g-1
Reaction score
40
Please stop calling it 'upload'.

Save the file as .shtml and see if your server parses this...
Code:
<!--#include virtual="menu.html" -->
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Please stop calling it 'upload'.

Save the file as .shtml and see if your server parses this...
Code:
<!--#include virtual="menu.html" -->

I'm fairly sure you need to configure the server to do that, in which case, PHP is easier.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Yes, as well as every other major HTTP server (most of them, at least).

In the case of Apache though, it requires mod_include to be installed and enabled, as well as an .htaccess file with the "Options +Includes" directive inside.
Not only that, but to allow it to work the way JerseyFoo stated, you'd have to add additional lines to the .htaccess:
Code:
AddType text/html .shtml
AddHandler server-parsed .shtml

In most modern servers, this isn't much of an issue, but most modern servers also have PHP installed, which can do the same thing with less work.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Ah, I see your point.
Disabling JavaScript is pointless though, as pretty much every modern website uses it, and there are no true threats to having it enabled.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Ah, I see your point.
Disabling JavaScript is pointless though, as pretty much every modern website uses it, and there are no true threats to having it enabled.

Enter browser incompatibilities.
There's a reason libraries like jQuery have an Ajax handler for you.
 

Slapshot136

Divide et impera
Reaction score
471
there are no true threats to having it enabled.

except for site looking through your browsing history and targeting you with deadlier ads

id list your options as the following:

1. manually copy + paste if it isn't to big of a hassle
2. create a small program/batch file that goes through and does it, and copies everything to a new directory and run this before updating to the server
3. finding a server that supports php (the client won't know the difference if you use php or not, all the other methods will have some inpact on the browsing experience of the client) or create your own server (possibly have your existing server just secretly redirect to your own server)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top