Hi All,
Is it possible to use includes dynamically in html.
Hopefully the following example will give an idea what I am rying to do.
Thanks in advance
Adam
<script language="javascript">
function checkFileToInclude(){
if (location.search == "?file1"){
return "<!--#include file='file1.html'-->"
}else{
return "<!--#include file='file2.html'-->"
}
}
</script>
<html>
..
..
<a href="www.mydomain.com/test?file1">Include File 1</a>
<a href="www.mydomain.com/test?file2">Include File 2</a>
..
..
<td>
document.write(checkFileToInclude())
</td>
..
..
..
</html> 14 1640
Adam wrote: Hi All,
Is it possible to use includes dynamically in html.
....
<script language="javascript"> function checkFileToInclude(){ if (location.search == "?file1"){ return "<!--#include file='file1.html'-->" }else{ return "<!--#include file='file2.html'-->" } } </script>
Lol not unless this script runs on the server... I assume you want to
perform the actions in the #include statements, and those should be
performed on the server side, since the JavaScript is executed on the
client side the server will never know what process.
The funny thing is that this may actually work, but then the other way
round from what you seem to expect: the server will, *before* sending
the result to the client, replace the SSI instructions with the content
of *both* html files and later on the JavaScript picks one of those to
use...
Cheers,
Guido
Adam wrote: Hi All,
Is it possible to use includes dynamically in html.
Hopefully the following example will give an idea what I am rying to do.
Thanks in advance Adam
<script language="javascript"> function checkFileToInclude(){ if (location.search == "?file1"){ return "<!--#include file='file1.html'-->" }else{ return "<!--#include file='file2.html'-->" } } </script>
<html> . . <a href="www.mydomain.com/test?file1">Include File 1</a> <a href="www.mydomain.com/test?file2">Include File 2</a> . . <td> document.write(checkFileToInclude()) </td>
. . . </html>
In addition to the two replies, you can also try using object elements
instead of server-side includes, which allows you to treat the content
of an object like an inline frame. Ie.,
<object id="file1" data="file1.html" type="text/html" width="100%"
standby="Loading file1.html...">
Your browser cannot render embedded HTML documents.
</object>
The difference is that your file1.html document should be a valid HTML
document, not just an HTML fragment. You can access that document
through the object's contentDocument property. I've used this method to
include sitewide menus on my websites.
In article <s5**********************@news4.srv.hcvlny.cv.net> , we*******@slider142.donttypethis.com enlightened us with... <object id="file1" data="file1.html" type="text/html" width="100%" standby="Loading file1.html..."> Your browser cannot render embedded HTML documents. </object>
I really like this method. This is the first time I've seen it for html
pages. Unfortunately, IE doesn't seem to support it.
Does anyone know what browsers do support this?
I tested Opera 7 and Netscape 7 and they were fine. IE 6, however,
didn't render anything at all, even the warning that it isn't supported.
Anyone test with Safari, Konqueror, etc? I assume Netscape 4 would not
support it.
I used the following doctype for both html files:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
Should I use a different one for this?
--
--
~kaeli~
Dijon vu - the same mustard as before. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace
kaeli wrote: In article <s5**********************@news4.srv.hcvlny.cv.net> , we*******@slider142.donttypethis.com enlightened us with...
<object id="file1" data="file1.html" type="text/html" width="100%" standby="Loading file1.html..."> Your browser cannot render embedded HTML documents. </object>
I really like this method. This is the first time I've seen it for html pages. Unfortunately, IE doesn't seem to support it.
Does anyone know what browsers do support this? I tested Opera 7 and Netscape 7 and they were fine. IE 6, however, didn't render anything at all, even the warning that it isn't supported. Anyone test with Safari, Konqueror, etc? I assume Netscape 4 would not support it.
I used the following doctype for both html files: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
Should I use a different one for this?
Heya kaeli,
I normally use the XHTML 1.1 standard with basic support for older
browsers, but it works in IE6 as well, at least if the document you're
calling is HTML. See the following two example pages in any browser: http://slider142.com/xhtml/objecttest.xhtml - The base document is XHTML 1.1 http://slider142.com/xhtml/objecttest.html - The base document is HTML
4.01 Strict
In article <sE**********************@news4.srv.hcvlny.cv.net> , we*******@slider142.donttypethis.com enlightened us with... Heya kaeli, I normally use the XHTML 1.1 standard with basic support for older browsers, but it works in IE6 as well, at least if the document you're calling is HTML. See the following two example pages in any browser: http://slider142.com/xhtml/objecttest.xhtml - The base document is XHTML 1.1 http://slider142.com/xhtml/objecttest.html - The base document is HTML 4.01 Strict
You know, when I went to your link, it worked fine, but when I tried it
locally with my file, it didn't work (IE file->open).
I realized I left something out - the height attribute. Apparently IE
needs that more than Netscape and Opera do, as it was shrinking it to 0
px. :)
Your original example didn't have the height specified. Your code on
this link has it.
Thanks!
--
--
~kaeli~
Who is General Failure and why is he reading my hard disk? http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace
On Fri, 28 May 2004 16:19:36 GMT, Ron
<we*******@slider142.donttypethis.com> wrote: Heya kaeli, I normally use the XHTML 1.1 standard with basic support for older browsers, but it works in IE6 as well,
no it does not, IE does not render XHTML 1.1. (other than as an XML
tree)
at least if the document you're calling is HTML. See the following two example pages in any browser: http://slider142.com/xhtml/objecttest.xhtml - The base document is XHTML 1.1 http://slider142.com/xhtml/objecttest.html - The base document is HTML 4.01 Strict
Use IFRAME.
Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jim Ley wrote: On Fri, 28 May 2004 16:19:36 GMT, Ron <we*******@slider142.donttypethis.com> wrote: Heya kaeli, I normally use the XHTML 1.1 standard with basic support for older browsers, but it works in IE6 as well,
no it does not, IE does not render XHTML 1.1. (other than as an XML tree)
Heya Jim,
The page I link to is standard XHTML 1.1 with document type and xml
prologue. It renders fine in IE 6 as HTML, not as an XML tree view, even
though IE doesn't recognize the document type.
at least if the document you're calling is HTML. See the following two example pages in any browser: http://slider142.com/xhtml/objecttest.xhtml - The base document is XHTML 1.1 http://slider142.com/xhtml/objecttest.html - The base document is HTML 4.01 Strict
Use IFRAME.
Jim.
I would use IFRAME as an example, but as it's been deprecated in XHTML
1.1 in favor of the coming XFrames standard, I decided to use object
instead. Even when writing HTML, I try to use elements that are
forwards-compatible for low maintenance.
On Fri, 28 May 2004 18:57:14 GMT, Ron
<we*******@slider142.donttypethis.com> wrote: Jim Ley wrote:no it does not, IE does not render XHTML 1.1. (other than as an XML tree)
Heya Jim, The page I link to is standard XHTML 1.1 with document type and xml prologue. It renders fine in IE 6 as HTML, not as an XML tree view, even though IE doesn't recognize the document type.
It doesn't render for me, I could make it render with some reg
hacking, but that's hardly a good thing, as it'll still be tag-soup,
and rendered badly. Use IFRAME. I would use IFRAME as an example, but as it's been deprecated in XHTML 1.1 in favor of the coming XFrames standard, I decided to use object instead. Even when writing HTML, I try to use elements that are forwards-compatible for low maintenance.
Quick question then in a HTML doc embedded in OBJECT what does the A
element do - replace the object, or the parent - which is the spec
compliant way? (it's not defined I believe btw.)
Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jim Ley wrote: On Fri, 28 May 2004 18:57:14 GMT, Ron <we*******@slider142.donttypethis.com> wrote: Heya Jim, The page I link to is standard XHTML 1.1 with document type and xml
<>prologue. It renders fine in IE 6 as HTML, not as an XML tree view, even though IE doesn't recognize the document type.
It doesn't render for me, I could make it render with some reg hacking, but that's hardly a good thing, as it'll still be tag-soup, and rendered badly.
Hmm, you're right. The XHTML file only renders in IE when I load it from
my computer. It may be because of the extra MSXML stuff I have installed.
Use IFRAME.
I would use IFRAME as an example, but as it's been deprecated in XHTML 1.1 in favor of the coming XFrames standard, I decided to use object instead. Even when writing HTML, I try to use elements that are forwards-compatible for low maintenance.
Quick question then in a HTML doc embedded in OBJECT what does the A element do - replace the object, or the parent - which is the spec compliant way? (it's not defined I believe btw.)
Jim.
The object behaves like an IFRAME in Mozilla. Ie., manually add the
'target="_parent"' or "_top" attribute to links within, or use
javascript to cover all links automatically. Unfortunately, only
javascript seems to work for IE.
kaeli wrote: [...] ar********@hotmail.com enlightened us with... Is it possible to use includes dynamically in html.
Yes, but not with javascript, which runs on the client. [...]
s/javascript, which runs on the client/client-side J(ava)Script/
There is server-side J(ava)Script as well.
PointedEars
kaeli wrote: In article <s5**********************@news4.srv.hcvlny.cv.net> , we*******@slider142.donttypethis.com enlightened us with... <object id="file1" data="file1.html" type="text/html" width="100%" standby="Loading file1.html..."> Your browser cannot render embedded HTML documents. </object> I really like this method. This is the first time I've seen it for html pages. Unfortunately, IE doesn't seem to support it.
Using the "object" element is not very different from using
the "iframe" element, and support is as well limited.
Does anyone know what browsers do support this?
All Mozilla/5.0 support it.
I tested Opera 7 and Netscape 7 and they were fine. IE 6, however, didn't render anything at all, even the warning that it isn't supported. Anyone test with Safari, Konqueror, etc? I assume Netscape 4 would not support it.
As it does not support the "iframe" element.
I used the following doctype for both html files: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
Should I use a different one for this?
You could use HTML 4.01 Strict since the "object" element is specified
there. Depends on what other HTML features you use in the document.
<http://www.w3.org/TR/html4/struct/objects.html#edef-OBJECT>
X-Post & F'up2 comp.infosystems. www.authoring.html
PointedEars
Ron wrote: Heya Jim,
My name is not Jim.
The page I link to is standard XHTML 1.1 with document type and xml prologue. It renders fine in IE 6 as HTML, not as an XML tree view, even though IE doesn't recognize the document type.
XHTML served correctly as application/xhtml+xml does not render in IE at all
(I'm using the latest, Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;
Q312461; .NET CLR 1.1.4322)), it wants to download the document since it
does not support the MIME type. And serving XHTML as text/html is utter
nonsense. As for XHTML, see my signature.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Daniel Keller |
last post by:
Hello!
I'm trying to set up a page system using "dynamic" SSI. That means that I
normally use the following on my website:
<!--#include virtual="file.inc" -->
Now I want to make this...
|
by: Materialised |
last post by:
Hi Everyone,
I apologise if this is covered in the FAQ, I did look, but nothing
actually stood out to me as being relative to my subject.
I want to create a 2 dimensional array, a 'array of...
|
by: Pascal Costanza |
last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Monday, February 13, 2006, VUB Campus Etterbeek
The VUB (Programming Technology Lab,...
|
by: James Bates |
last post by:
Hope someone can help me out with something - I'm a HTML/CSS developer
who know's a little PHP, which I use to make smaller sites
semi-dynamic, I want to expand on what i'm currently doing but need...
|
by: foker |
last post by:
I have a file with a list of times in it in the form hh:mm:ss. The file
starts with a single INT like 460. That int is the number of times in
the file so I can size my dynamic array correctly. I...
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these...
|
by: pratap |
last post by:
Is there any way in which one can link a.so(Class implementation by
Vendor A in a dynamic library) and b.so(Class implementation by Vendor
A in a dynamic library) and use it in 1.cpp
where 1.cpp...
|
by: thetechturf.com |
last post by:
I have some simple dynamic content pages (included below). I need to
know how to add specific meta tags (ie. description, keywords, ect.),
as well as extra specific header coding to a page. I would...
|
by: karen987 |
last post by:
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The...
|
by: Ajinkya |
last post by:
I have writen a program for a game called game.exe
Now it includes a player part to which has to be a function to be
writen by someone else.
Now I want to provide this exe to some tester who...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
| |