Solved

How to Input a extern file into a html document.

Posted on 2001-06-16
5
152 Views
Last Modified: 2010-04-09
Well here we go, one of my "seems to be hard but is easy" question.
I have a part of a html document looking like that:

.
.
.
<table cellpadding=0 cellspacing=0 border=0 width=180>
          <tr><td><td></tr>
<tr><td background="pix/short_section_bar_bg.gif" height=14 valign=center>
&nbsp;&nbsp;.: Special :.
</td></tr>
</table>
               
<table cellpadding=2 border=0 width=180 bgcolor=#827968>
        <TBODY>
<tr><td width=180>
<script language="JavaScript">
<!--
i=Math.floor(Math.random()* 4 );
switch(i)
{
case 0:
document.write("<img src='random/image1.jpg'>");
break;
case 1:
document.write("<img src='random/image2.jpg'>");
break;
case 2:
document.write("<img src='random/image3.jpg'>");
break;
case 3:
document.write("<img src='random/image4.jpg'>");
break;
case 4:
document.write("<img src='random/image5.jpg'>");
break;
case 5:
document.write("<img onmouseover='color(this)' onmouseout='gray(this)' src='random/image6.jpg'>");
break;
}//-->
</script>
</center>

</td></tr>
</TBODY>
</table>
.
.
.

AND i want this small script not really IN the html file, i want something like that in the Html File:

.
.
.
<script language="?Html?" src="scripts/special.js">
</script>
.
.
.

When the User starts the *.html file, the script should be loaded like above.
I need this script for my website: www.speedlight.de
Because i dont use any frames and i want easily change a part of the pages (its not easy to understand ;-))
Well, hope you understand!
Thank
You
Consti
0
Comment
Question by:Consti
  • 3
  • 2
5 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6198095
Put this in a file called scripts/special.js
i=Math.floor(Math.random()* 4 );
switch(i)
{
case 0:
document.write("<img src='random/image1.jpg'>");
break;
case 1:
document.write("<img src='random/image2.jpg'>");
break;
case 2:
document.write("<img src='random/image3.jpg'>");
break;
case 3:
document.write("<img src='random/image4.jpg'>");
break;
case 4:
document.write("<img src='random/image5.jpg'>");
break;
case 5:
document.write("<img onmouseover='color(this)' onmouseout='gray(this)' src='random/image6.jpg'>");
break;
}
Then remove the scripting from the page and just put in:

<script language="JavaScript" src="scripts/special.js">
</script>


The code on the page will look like this:
<table cellpadding=0 cellspacing=0 border=0 width=180>
<tr><td><td></tr>
<tr><td background="pix/short_section_bar_bg.gif" height=14 valign=center>
&nbsp;&nbsp;.: Special :.
</td></tr>
</table>

<table cellpadding=2 border=0 width=180 bgcolor=#827968>
<TBODY>
<tr><td width=180>
<script language="JavaScript" src="scripts/special.js">
</script>

</center>

</td></tr>
</TBODY>
</table>

The code in the .js file will get executed during the load to generate the
other code.

Cd&
0
 

Author Comment

by:Consti
ID: 6198324
And when i just want to input some text?
A non-Javascript thing?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 50 total points
ID: 6198372
Three options:

Client side is with js files.

server side you can generate dynamically with script or if the server is configured for includes you can bring them in with:

<!--#include file="filename.shtml"-->

To use includes the server must be configured to recognize them.  

Cd&
0
 

Author Comment

by:Consti
ID: 6198604
Thank You
//Visit www.speedlight.de to see the script in action ;-) lol
Consti
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6198614
I can't read because I don't know German, but it looks great.  Glad I could help.  Thanks for the A. :^)

Cd&
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to change the link of an image using md5 in php ? 3 47
Index on a Table 6 25
Help in good tutorials for PHP, HTML and CSS 6 42
Asp in script 6 39
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question