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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

? "INCLUDE FILE" from inside vbscript in *HTML* page?

Status
Not open for further replies.

MVisconte

Programmer
Joined
Jun 17, 2002
Messages
105
Location
US
...as if the title weren't bad enough...

Is there any way to use "INCLUDE FILE" in a .htm page running locally under IE? I use IE to gain the "script=vbscript" advantage to replace functionality that was lost when a server was blocked. (nutshell)

I wrote some HTML-web-page "fetching" ASP pages for a remote server that has AspTear on it. The pages worked fine, but the server is blocked from where I now work.

I replaced the .asp pages with local pages in .html using the Microsoft.XMLHTTP object to replace the ASPTear.

THEY work ok, but I have a problem w/ size and redundant code. I wound up splitting the rather longish page into four pages, and each page has the same subs, which offends my sense of efficiency.

This brings me back to me question...

I know how to use "include file" in ASP, but I don't have a webserver to play w, so that is out. I can get functionally equivalent code in the vbscript embedded in the HTML, but I haven't figured out if I can do the...

non-ASP vbscript INCLUDE FILE in htm pages...

Any thoughts?
Any Answers?

Tnx.

Oh, it's NOT a "necessity", it's not for work... I run a local IE version of a quote/cartoon puller. Cheezy, I know, but I get all the quotes and cartoons I need in just a few seconds. Aren't you disgusted w/ me now?
 
You can &quot;include&quot; script by using the regular <script> tag with the SRC attribute.

Client-side includes of HTML fragments are a little messier. If it is only needed for IE, there was a technique using the Tabular Data Control discussed here earlier. I'll post the thread link if I find it, but 'til then try a search of this forum for {client include tdc} and see if you can find it.

Other techniques include fetching fragments from files on the server (or file URLs) using MS's XMLHTTP component. This can handle &quot;text&quot; as well as structured XML data. You get the text and jam it into a <div>'s innerHTML much as the TDC example was doing.
 
Hm... I tried searching &quot;all words&quot;, all forums, on both

Client include tdc
and
client include tabular data control

with no luck.

Someone else had mentioned innerHTML:

&quot;well if you create your page with <div> tags where you want the includes and then give each a unique id you can create external script files for each block which load the content using .innerHTML&quot;

but I haven't found anything in the div documentation or innerhtml documentation that explains external files yet. I vaguely remember (years ago) something about being able to source external javascript repositories in the script definition. SOMEthing like...
script=javascript source=somefile.js

Does that sound familiar at all?
 
I searched too. Maybe the thread got deleted, though it wasn't very old (last 2 months?) nor offensive. I know Tek-Tips is working on search improvements.

You can always insert smething into innerHTML of a DIV or SPAN or TD or something. The trick is getting that something.

I suppose one might embed a bunch of text into strings in a .vbs or .js, but that's sort of messy. The two easy-to-use components that can grab text at a URL are the TDC and XMLHTTP controls though.

Maybe I can post a sample a bit later on.
 
I figured out my mistake... I was doing my src wrong. It works w/

<script language=&quot;vbscript&quot; src=&quot;MyCode.vbs&quot;></script>

in the header. Hurrah.

Here's a cookie (put in local html and run under IE):
' Pull the Picture of the Day (doesn't use xmlhttp)

Function POD()
' Get Picture of the Day from Steve's Digicams...
' Size to 50% display. SAVE will be at 100%
' Form like
'
' dim StevePOD, StevePODir, StevePODAy,
' dim SteveSite, Pct50, HW, SteveImage
' dim SteveURL
Pct50 = Chr(34) & &quot;25%&quot; & chr(34)
HW = &quot; width=&quot; & Pct50
SteveURL = &quot; StevePPage = &quot;/daily_dpotd.html&quot;
SteveSite = chr(34) & SteveUrl & StevePPage & chr(34)
' Provides LINK to site.
' INCLUDES double-quotes around URL.
StevePod = SteveURL & &quot;/dpotd/&quot;
StevePODir = left(monthname(month(Now)),3) &_
year(Now) & &quot;/&quot;
StevePODAy = right(&quot;0&quot; & month(Now), 2) &_
right(&quot;0&quot; & day(Now), 2) &_
year(Now)
StevePOD = StevePOD & StevePODir & StevePODay & &quot;.jpg&quot;
' Diagnostic
' document.write StevePODir & StevePODay & &quot;.jpg&quot;
SteveImage = &quot;<img &quot; & HW &_
&quot; src=&quot; & chr(34) & StevePOD & chr(34) &_
&quot; ALT=&quot; & chr(34) &_
&quot;Steve's Digicams Pic-o-the-Day&quot; &_
chr(34) & &quot; Align=Left>&quot;
POD = &quot;<a href=&quot; & SteveSite & &quot;>&quot; &_
SteveImage &_
&quot;</a>&quot;
End Function


Use: Put function above in script sectio of ie web page.
Call by adding script part in body:
<script language=&quot;vbscript&quot;>
document.write POD
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top