|
-
May 3rd, 2001, 11:01 AM
#1
Thread Starter
Frenzied Member
If Include
I'm using the Sun/Netscape ClientSniffer Script, which provides a series of boolean variables such as is_ie4up. If anyone knows of a better sniffer script, that would be nice. I was trying to use the OO one, but its object name is the same as a DynAPI object. Again, if anyone has had better luck with other cross-platform scripts such as DynAPI, please let me know.
My question is... is there a way to do the following:
Code:
<script language='JavaScript'>
if (is_nav) {
<!--- #include virtual="nav.inc"-->
}
else if (is_ie) {
<!--- #include virtual="ie.inc"-->
}
</script>
The tricky part is... the inc files have no scripting in them, just HTML, and I do not feel like adding document.writeln to each line of the inc files. Basicly, the question is, is there a way to load a block of HTML file into a script to be shown to the browser. When the client-side script executes, it won't see the includes, that is done server-side. So how do I wrap the includes so I don't have to dcument.writeln each line of the inc?
Does that make any sense?
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
May 3rd, 2001, 03:14 PM
#2
I was unaware that javascript can be executed on the server side.
Scoutt
-
May 3rd, 2001, 03:32 PM
#3
Thread Starter
Frenzied Member
Well, actually, there is server-side JavaScripting and JSP, but I'm not using either, all of my JavaScripting is client-side.
So, I'm confused as to why you bring it up.
The includes are server-side, but that is not a function of JavaScript, it is the web server (in this case IIS).
PS To really confuse the issue, this is embedded in an ASP using VBScript.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
May 3rd, 2001, 04:43 PM
#4
Thread Starter
Frenzied Member
Well, what I'm tying to accomplish is (and I just thought of a really kludge way of doing it)...
This ASP page does a SQL query and a lot of math figuring out incidents and outages and downtimes. Anyway, there are a couple of include files, which are themselves full of VBScript. They parse the data into readable tables and put the appropriate colors behind each situation. They were orginally part of the main ASP but it go so big that I had to break it into seperate files.
Anyway... the way I'm showing the tables of data, with some user interaction, relys on DHTML and JavaScript on the client-side. Regretably, I have to maintain compatiblity with IE 4, 5, Navigator 4, Netscape 6, and Opera 5. I'm doing browser detection in the client-side JavaScript, not in the server-side VBScript.
Anyway... the stuff in the include files themselves don't care what time of browser it is. So I'm going to do the following...
Code:
<%
'ASP work with VBScript
%>
<html>
<head>
<script language='JavaScript' src='ClientSniffer.js'></script>
<script language='JavaScript' src='DynAPI.js'></script>
</head>
<body>
<!--- #include virtual="header.inc"-->
<%
Response.Write("<p>Some Intro HTML here</p>")
%>
<script language='JavaScript'>
if (is_ie4up) {
// document.writeln IE 4 and 5 specific tag openings
}
else if (is_nav4) {
// document.writeln Navigator 4 specifig tag openings
}
else if (is_nav6up || is_gecko) {
// document.writeln Gecko specific tag openings
}
else if (is_opera5up) {
// document.writeln Opera specific tag openings
else {
document.writeln("<p>Your browser sucks.</p>")
}
</script>
<!--- #include virtual='table.inc'-->
</script>
if (is_ie4up) {
// document.writeln IE 4 and 5 specific tag closings
}
else if (is_nav4) {
// document.writeln Navigator 4 specifig tag closings
}
else if (is_nav6up || is_gecko) {
// document.writeln Gecko specific tag closings
}
else if (is_opera5up) {
// document.writeln Opera specific tag closings
}
</script>
<!--- #include virtual='trailer.inc'-->
</body>
What I was trying to do before was use one large script block to put the opening and closing browser specific stuff around the basic HTML that the inc would generate. I can do the same thing if I use two script blocks.
Sucks, but works.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
May 3rd, 2001, 05:18 PM
#5
I see, man you have your work cut out for you. why go all that way? is it because the layout just won't work on some browsers? if there is not that much difference than why worry about it. I run a website and I get a lot of hits from WebTv, java 1.1, and LibWWW browsers. The webTv browser is a real pain in the a** to work with. it shows the page very different. I can understand if the page really looks like crap and that is why you are trying to set it up like you are.
I don't know if there is a big difference between javascript and php when they do an include but all my includes for php is just the html part with nothing special in them. sorry I couldn't be tha tmuch help for ya.
Scoutt
-
May 3rd, 2001, 06:51 PM
#6
PowerPoster
Ok, i am confused, do you have the ability to use a server scripting language? If so, why not keep it all server side? For example:
to detect the browser with ASP:
Code:
Request.ServerVariables("http_user_agent")
Does this help at all?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
May 3rd, 2001, 07:15 PM
#7
Thread Starter
Frenzied Member
I could do server-side client detection, but I have to do client-side detection. I'm making some of the tables dissappear, and changing the color on some of the buttons dynamicly. I could do server-side detection and send different JavaScripts down, but all that stuff is done with DynAPI, and it is client-side. I figured since I'm already dong client-side detection for that, I would keep doing.
Mmmm... you know... I could do some server side and only send down the DynAPI scripts if the browser is atleast IE4+ or Netscape 6. And then I could use client side for the particular differences between IE and Netscape.
I should go back to the drawing board for this whole thing. But hey, I'm already using entirely too many different technologies, what does it matter if I look for a few more to add.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
May 3rd, 2001, 07:30 PM
#8
PowerPoster
Yeah, i have been in that spot before myself. I hate having to rewrite everything, but sometimes it is necissary. BTW, what are you using DynAPI for?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
May 3rd, 2001, 08:28 PM
#9
Thread Starter
Frenzied Member
Originally, it was create the dynamic elements for Navigator 4, IE 4-5, Opera, and Netscape 6, but since it doesn't work under Navigator 4 and DynAPI doesn't support Opera... I don't guess there is a reason.
Netscape 6 and IE 4-5 should work with the same bit of code, but I havne't tried it, yet. I'm kind of scared to.
When I get back into the office on Monday I play with it.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
May 4th, 2001, 08:57 PM
#10
PowerPoster
Too bad it does not support opera. I am becoming quite fond of that little browser! I have heard that it has a few problems with it's DOM though.
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|