473,788 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SSI with JavaScript

How can I include a file using JavaScript?

document.write( '<!--#include file="myfile.ht m" -->')

won't work because of the commenting. Is there a way to fool
JavaScript into including the file at the appropriate point?

Currently I am calling iframes instead of using SSI. You can see why
I'd want to switch.

If it cannot be done with SSI, is there another inclusion format that
will work?

(For those who want to chastise me for using JavaScript at all, rest
assured I am not abusing it and that the appropriate <noscript> tags
are in use.)
Jul 20 '05 #1
6 8984
Jane Withnolastname wrote:
How can I include a file using JavaScript?

document.write( '<!--#include file="myfile.ht m" -->')

won't work because of the commenting. Is there a way to fool
JavaScript into including the file at the appropriate point?
XmlHttpRequest
(For those who want to chastise me for using JavaScript at all, rest
assured I am not abusing it and that the appropriate <noscript> tags
are in use.)

--
Iso.
FAQs: http://html-faq.com http://alt-html.org http://allmyfaqs.com/
Recommended Hosting: http://www.affordablehost.com/
Web Design Tutorial: http://www.sitepoint.com/article/1010
Jul 20 '05 #2
Jane Withnolastname <Ja************ **********@yaho o.com> wrote:
How can I include a file using JavaScript?

document.write ('<!--#include file="myfile.ht m" -->')

won't work because of the commenting.


Uh no. It won't work because JavaScript is handled by the browser and
SSIs are handled by the server. So by the time the JavaScript is
parsed it is far too late for the SSI to be parsed.

It may help if you gave a bit more background. Why does this file need
to be included by JavaScript, why can it not just be included once?

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #3
On Mon, 29 Sep 2003 10:05:18 +0100, Steve Pugh <st***@pugh.net > wrote:
Jane Withnolastname <Ja************ **********@yaho o.com> wrote:
How can I include a file using JavaScript?

document.writ e('<!--#include file="myfile.ht m" -->')

won't work because of the commenting.


Uh no. It won't work because JavaScript is handled by the browser and
SSIs are handled by the server. So by the time the JavaScript is
parsed it is far too late for the SSI to be parsed.

It may help if you gave a bit more background. Why does this file need
to be included by JavaScript, why can it not just be included once?

Steve


OK.
When I list something on eBay, I add it to my web page. That's easy.
But I don't want to have to be there and on the ball in order to take
it off my web page when the auction ends. Therefore, I use a
JavaScript to "expire" it at the proper time.
If the auction is not over, the script shows the iFrame. If the
auction is over, it reverts to just an eBay button (which is what
noscript browsers see anyway).
Ideally, I want to rid myself of iFrames, but without SSI, I cannot
figure out how to get another page into my main page.
Maybe I'm asking for the impossible. If that's the case, I guess I'm
stuck with the iFrames - which I hate just as much as everyone else
here!
Thanks.
Jul 20 '05 #4
On Mon, 29 Sep 2003 09:32:01 +0000, Isofarro
<sp*******@spam detector.co.uk> wrote:
Jane Withnolastname wrote:
How can I include a file using JavaScript?

document.write( '<!--#include file="myfile.ht m" -->')

won't work because of the commenting. Is there a way to fool
JavaScript into including the file at the appropriate point?


XmlHttpReque st


I'm sorry, I don't know what that means.
Can you elaborate? Or point me in the direction of a tutorial that
will further explain this or tell me how to implement it?
Unless I'm missing something, this is XML, rather than HTML. Is it
much different? Or can it be included in a HTML document?
(I bet that made me look really stupid, but I have absolutely no
experience with XML and, frankly, it scares me. But if it solves my
problems, I will do it.)
Jul 20 '05 #5
Sometime around Thu, 02 Oct 2003 02:22:44 GMT, Jane Withnolastname is
reported to have stated:
OK.
When I list something on eBay, I add it to my web page. That's easy.
But I don't want to have to be there and on the ball in order to take
it off my web page when the auction ends. Therefore, I use a
JavaScript to "expire" it at the proper time.


That could be done fairly easily via SSI and some server-side scripting
(PHP, ASP, etc).

--
Mark Parnell
http://www.clarkecomputers.com.au
Jul 20 '05 #6
Jane Withnolastname wrote:
On Mon, 29 Sep 2003 09:32:01 +0000, Isofarro
<sp*******@spam detector.co.uk> wrote:
Jane Withnolastname wrote:
How can I include a file using JavaScript?

document.write( '<!--#include file="myfile.ht m" -->')

won't work because of the commenting. Is there a way to fool
JavaScript into including the file at the appropriate point?
XmlHttpReques t


I'm sorry, I don't know what that means.
Can you elaborate?


XmlHttpRequest is an object in both Internet Explorer 5+ browsers and
Mozilla based browsers. It allows a page to request resources over HTTP.

<http://jibbering.com/2002/4/httprequest.htm l>
<http://www.15seconds.c om/issue/020606.htm>
<http://www.xulplanet.c om/references/elemref/ref_XMLHttpRequ est.html>
<http://www.scottandrew .com/weblog/2002_04#a000257 >
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/xmlsdk30/htm/xmobjxmlhttpreq uest.asp>
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/xmlsdk30/htm/xmobjpmexmlhttp request.asp>
Unless I'm missing something, this is XML, rather than HTML.
It allows any sort of data to be transferred, not just XML.
Is it
much different? Or can it be included in a HTML document?
Script using XmlHttpRequest functions is within the page, it requests an
external resource - be it XML, HTML, plain text, whatever.

Then just insert that into the document at the correct place using DOM
techniques such as getElementById( ) and appendChild().

DOM reference:
<http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html>

This is what I do here:
http://www.isolani.co.uk/atomClient/atomClient.html

Select an option from the drop down list, and click "Get Blog Entries", this
fires off a request for an XML document and extracts a list of entries
which dynamically populates the next page which is the "Entries from
selected server:" page.

(I bet that made me look really stupid, but I have absolutely no
experience with XML and, frankly, it scares me. But if it solves my
problems, I will do it.)


You don't need to use XML if you don't want to. As long as you send the data
in a manner you can insert it in the right place, then the data can be of
any format. I chose XML because that was the format the data I needed to
work with was already in.
--
Iso.
FAQs: http://html-faq.com http://alt-html.org http://allmyfaqs.com/
Recommended Hosting: http://www.affordablehost.com/
Web Design Tutorial: http://www.sitepoint.com/article/1010
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.