Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSI - I'm a beginner and need direction! 6

Status
Not open for further replies.

JennyW

Technical User
Mar 1, 2001
323
CA
SERVER SIDE INCLUDES

I want to make a site that has loads of pages.
The borders, menu and logo of this site are all images and all appear on every page on my site.

Right now, if I don’t use SSI and if I want to make changes to any re-appearing images on my site then I’d have to edit those changes individually - on every single page.

However, if I do use SSI, then I can edit those images once and my changes will be applied to every page.

I’m not too sure how I can go about doing this. Does anyone know how I can get started?

Note: I’m not running my scripts with Apache. I’m running them on my hosts server.

Thanks for reading,
Jenny
 
Hi Jenny,

Ok, now listen up: remove the <script language='javascript'> and </script> tags from your javas.js file.

Here's your code from my browser's cache:


<script language=&quot;JavaScript&quot;>
Code:
<!--
function MM_showHideLayers() { //v2.0
  var i, visStr, args, theObj;
  args = MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) { //with arg triples (objNS,objIE,visStr)
    visStr   = args[i+2];
    if (navigator.appName == 'Netscape' && document.layers != null) {
      theObj = eval(args[i]);
      if (theObj) theObj.visibility = visStr;
    } else if (document.all != null) { //IE
      if (visStr == 'show') visStr = 'visible'; //convert vals
      if (visStr == 'hide') visStr = 'hidden';
      theObj = eval(args[i+1]);
      if (theObj) theObj.style.visibility = visStr;
  } }
}
//-->

</script>


Remove what's in red. You might have fixed javas.txt and forgotten javas.js The include works fine, but again, when I retrieve javas.js from my cache, it still contains the dreaded <script> tags...

Bye.
 
Hi again,

BTW, in IE, nothing is suppose to show up between the script tags in the head section of your HTML page when you're using an external js file. Anything that you would put there (in the HMTL page) would be ignore by the browser, it would only act on what's in the external js file.

Bye.
 
I tested the script on IE5+ and it worked fine as you have it, but what I can see that your doing wrong is calling the file wrong.

You need to know where the file is located on your server which from what I've seen is located on the top tier meaning the same level as your shtml page and it is not in it's own folder, correct? If so, try this....


<script src=&quot;javas.js&quot;></script>

You don't need &quot;./javas.js&quot; becuase that means nothing to the server, a slash indicates a folder in the file structure and this is a file not a folder. If you decide to place your script file in a seperate folder as you should for all your scripts you can refer to the file like so...

'includes/javas.js' includes is a folder for all your scripts

Or if you decide to place your web pages in a seperate folder and still have your scripts in their folder you can call them like so...

'../includes/javas.js'

the .. tells the server to go one folder up in the heirarchy and then search for the folder and file names you have specified in that higher tier. You can traverse up as many folders/directories as needed like so...

'../../../includes/javas.js'

this says that the server should go three sections up and then look for the specified path.

I think it was that you were calling the file wrong and thus it was not being loaded into your page and creating all of those errors since if you were to paste that file into your page inside SCRIPT tags it works. I hope this solves your problem.


Rocco is the BOY!!
M O T I V A T E!!!!!!!!!

 
Also... you need to remove the SCRIPT tags from the javas.js file becuase that type of file should only have javascript inside since what is happening when you SRC to this extrnl file is that the contents of the file are pasted into the tag you called it from. The pasted text would look like this if you kept the SCRIPT tags in...

<script src=&quot;javas.js&quot;></script>

is equal to ...

<script>
<script>
MM_ShowHideLayers(){

.....
}
</script>
</script>

if you leave the script tags in.


TAKE THE SCRIPT TAGS AND OTHER HTML TAGS OUT OF .JS FILES (ONLY SCRIPT CODE)
 
Hi,

You don't need &quot;./javas.js&quot; becuase that means nothing to the server

Yes, it means something to the server, the ./ means same directory.

Bye.
 
Success! I love it!
Thanks guys! Thank you so much!

Yahve, you wrote:
> You might have fixed javas.txt and forgotten javas.js

That’s exactly what I did wrong. Darn. Oh well, sometimes these things happen : )

If you want to check out my Successful results visit this url:

=====================

OneStiffRod wrote:
> '../../../includes/javas.js'
> this says that the server should go three sections up and then look for the specified path.

I always thought that ../filename.js meant that the server will look for my file from the first folder (root folder)?

=====================

Is it possible to call DHTML scripts using the External Javascript File method?
Can I put the DHTML scripts in my .js file?


Here’s what my DHTML script looks like:

Here’s where I got it:


I don’t necessarily want to use the DHTML script above. I just need to know if I can call them in a .js file?

=====================

Is it possible to use SSI to call < html > code?

=====================

Thanks so so much!
Jenny
 
Hi,

Bravo! and you're welcome...

I always thought that ../filename.js meant that the server will look for my file from the first folder (root folder)?

/ means root
./ means same directory
../ means one directory up
../../ means two directories up
../samelevel/file.name goes to a file in a directory at the same level as the directory you're calling it from...

Is it possible to call DHTML scripts using the External Javascript File method?
Can I put the DHTML scripts in my .js file?

No problems... just remove those <script> tags ;-)

Is it possible to use SSI to call < html > code?
Yes it is. Just remember that the content of the file you call will be inserted as is exactly at the spot you call it from.


Bye.


 
Hi,

I’m having trouble calling a DHTML script within a .js file.

I have a DHTML script that creates color scrollbars (you can only view these scrollbars using IE5.5 and NS6).

Here’s the script I’m trying to call:


[tt]<!--
BODY{
scrollbar-face-color:#75EA00;
scrollbar-arrow-color:brown;
scrollbar-track-color:#333333;
scrollbar-shadow-color:'';
scrollbar-highlight-color:'';
scrollbar-3dlight-color:'';
scrollbar-darkshadow-Color:'';
}
-->[/tt]


- I took the < script > tags out of the above code.
- I inserted the code in to the same document my rollover javascript is in (javas.js).
- I then uploaded, and the scrollbar script didn’t work, and to make matters worse my rollover script stopped working.
- So, I took out the scrollbar script and left the javas.js file with only the rollover script in it. I uploaded it and the rollover worked fine again.
- Then I tried making a separate file called javas_002.js and I only put the scrollbar script in it. I put the following code in my webpage:

[tt]<script type='text/javascript' src='javas_002.js'></script>[/tt]

- I uploaded both the webpage and the javas_002.js script, but the scrollbars didn’t appear on the screen.


Here’s my page:


Here’s an example of color scrollbars:



I don’t know what I’m doing wrong?

====================

/ means root
./ means same directory
../ means one directory up
../../ means two directories up
../samelevel/file.name goes to a file in a directory at the same level as the directory you're calling it from...


Thanks, that explanation was just what I needed!
Jenny
 
Hi Jenny,

It is not suppose to work, because
Code:
<!--
BODY{
scrollbar-face-color:#75EA00;
scrollbar-arrow-color:brown;
scrollbar-track-color:#333333;
scrollbar-shadow-color:'';
scrollbar-highlight-color:'';
scrollbar-3dlight-color:'';
scrollbar-darkshadow-Color:'';
}
-->

is not a javascript but simple style information. Put this code in a file with a .css extension and refer to it from the head of your HTML with a style tag:
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;./file.css&quot; />

if you look at you will see that the code for the scrollbar is between style tags and not script tags.

I think you should understand that there really is no such thing as a DHTML script. DHTML (or dynamic HTML) is just a way to make your pages come alive by using HTML, CSS (cascading style sheets) and a script language, which almost every time is javascript. HTML formats your content, CSS defines the appearance (color, position, etc...) and javascript allows you to modify both without reloading the document. See
to get an idea of what I'm talking about. People just refer to the whole thing as DHTML scripts but they really should not. Just as there's no such thing as a CGI script (strictly speaking) because CGI is not a language.

Bye.
 
Hi yahve,

You wrote (for the scrollbars code):
Put this code in a file with a .css extension and refer to it from the head of your HTML with a style tag:
[tt]<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;./file.css&quot; />[/tt]

Instead of the code you posted I used this…
[tt]<link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;>[/tt]

What’s the difference between the two?


Here’s my page with the code above inserted:

========================

if you look at you will see that the code for the scrollbar is between style tags and not script tags.

Is it safe to say everything with <script> tags is Javascript and everything that has <style> tags is CSS?

========================

I think you should understand that there really is no such thing as a DHTML script. DHTML (or dynamic HTML) is just a way to make your pages come alive by using HTML, CSS (cascading style sheets) and a script language, which almost every time is javascript.

Other than Javascript, HTML and CSS are there any other scripts that help make up DHTML?

========================

Also, thanks for the info. with DHTML and the link on DHTML (oops, not DHTML)!

Take care,
Jenny
 
Hi,

What’s the difference between the two?

Not much. I usually close empty tags with a / (xhtml specifications I have a habit of defining as many attributes as possible, just in case.

Is it safe to say everything with <script> tags is Javascript and everything that has <style> tags is CSS?

No. Everything in <script> tags is not javascript. It can be other languages, like VBScript or Perl for example. As for the <style> tag, it should only contain valid style statements in the language indicated by the type attribute which for CSS2 is text/css, but note that it means that it could be some other language.

Other than Javascript, HTML and CSS are there any other scripts that help make up DHTML?

Other than JavaScript, you mean... Yes, in fact, you could use other languages to create DHTML (VBScript, maybe others). I guess that as long as the language can access the document object, it could be used.

Bye.
 
Hi yahve!

I usually close empty tags with a / (xhtml specifications I have a habit of defining as many attributes as possible, just in case.

- Say I have a webpage that calls an image named: running.jpg

- My webpage is in the same folder as running.jpg

- Within my webpages code, can I call running.jpg any of the following ways:

running.gif
/running.gif
./running.gif


Are there any differences between the above?

============================

As for the <style> tag, it should only contain valid style statements in the language indicated by the type attribute which for CSS2 is text/css, but note that it means that it could be some other language.

What do you mean “type attibute?”

============================

Thanks,
Jenny
 
Hi,

If the path of your HTML file is something like:
c:\webroot\jenny\yourpage.html and the URL is
; if you refer to your jpg like so /running.jpg, the server is going to look for it at
c:\webroot\running.jpg (which is not what you want.
Again, / refers to the root of the server (in the example: ./ refers to the same directory your calling from,
../ refers to one directory up, etc...

I think you should read up on this. Remember that you can point to a file either with an absolute or relative path. As with all code, don't leave anything to chance and you will avoid surprises.

As for the style tag, it has a type attribute which should be defined, it also has a media attribute. Of course, most of the attributes of HMTL tags have default values. Even so, I believe in defining as many attributes as possible if only to avoid confusion... and to get the results you want.

For example, a lot of pages on the web have no value for the bgcolor of the body (either in the body tag or in css). The writers of these pages assume that surfers do not change the default settings of their browsers (or they check their pages with a browser with default settings). The default value for the bgcolor of the body is white. Well this is not the case on my computers. These pages appear with a gray bgcolor in my browser. It's very ugly when the background suppose to be white. Check out yahoo.com and tell IE not to use windows colors
(tool->options->colors) and you'll see what I mean.

Bye.
 
Remember that you can point to a file either with an absolute or relative path.

Let me know if I’m right:

Absolute path: ./file_name.html

Relative path:
======================

For example, a lot of pages on the web have no value for the bgcolor of the body (either in the body tag or in css). The writers of these pages assume that surfers do not change the default settings of their browsers (or they check their pages with a browser with default settings). The default value for the bgcolor of the body is white. Well this is not the case on my computers. These pages appear with a gray bgcolor in my browser. It's very ugly when the background suppose to be white. Check out yahoo.com and tell IE not to use windows colors (tool->options->colors) and you'll see what I mean.


I went to yahoo.com and changed my colors. You were right, it does look worse. I’m surprised a legitimate site like yahoo.com hasn’t defined that attribute in their code.


So basically, to my understanding, “type attribute” is the following:

- something that “nice” to have, but it’s not a “need” to have.
- overrides defaults, by defining settings
- gives info. to the code reader about what language or code is being used

Am I on the right track?

======================

Thanks again yahve!
Jenny

Ohh, and thanks for the info. in the last post. It was helpful – cleared things up!
 
Hi,

Let me know if I’m right:
Absolute path: ./file_name.html
Relative path:

It's the other way around! A relative path is a path relative to where you are in the filesystem, and an absolute path is a path that points to the &quot;object&quot; from anywhere, without reference to a specific point.

So basically, to my understanding, “type attribute” is the following:

- something that “nice” to have, but it’s not a “need” to have.
- overrides defaults, by defining settings
- gives info. to the code reader about what language or code is being used

Am I on the right track?

Not quite. According to the W3C's HTML 4.01 specification:

[...]
Authors must specify the style sheet language of style information associated with an HTML document.
[...]
Documents that include elements that set the style attribute but which don't define a default style sheet language are incorrect.
[...]
Start tag: required, End tag: required

Attribute definitions

type = content-type [CI]
This attribute specifies the style sheet language of the element's contents and overrides the default style sheet language. The style sheet language is specified as a content type (e.g., &quot;text/css&quot;). Authors must supply a value for this attribute; there is no default value for this attribute.
[...]

So, there is no default, therefore you must specify the type. W3C's specification are not suppose to make code &quot;nice&quot;, but rather to make it standard, more accessible and easier understand, both for the readers and for the programs that render it.

Bye.
 
Hi yahve,

I’m still poking around!

type = content-type [CI]
This attribute specifies the style sheet language of the element's contents and overrides the default style sheet language. The style sheet language is specified as a content type (e.g., &quot;text/css&quot;). Authors must supply a value for this attribute; there is no default value for this attribute.



What happens if the author doesn’t supply a value for the attribute?
What does a value for an attribute look like?

I’m gonna take a stab at this:
The green is the attribute and the red is the value?

type = content-type [CI]

and or

type = content-type [“text/css”]

==========================

Thanks yahve!
Jenny
 
Hi,

The syntaxe is:

<tag attribute=&quot;value&quot;>...</tag>

for example:

<style type=&quot;text/css&quot;>...</style>

The [CI] in the type attribute definition I gave you is information about the attribute (not part of the attribute), and in this case means that the value of the type attribute of the style tag is Case Insensitive.

So it should be:

type=&quot;text/css&quot; and you know by the [CI] in the definition that the value is not case sensitive (so it could be &quot;text/CSS&quot; or &quot;Text/Css&quot;...)

Bye.
 
Hi yahve!

I have to say thanks so much for all your help. I really really appreciate it!

I now understand type attributes a whole lot more as well, as a heap of other things.

Thanks again, your help was invaluable :)
Jenny
 
Hi Jenny,

I was glad to help. Explaining something to someone else is just about the best way to really master the information.

Bye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top