Re: conditional javascript script
From: Steve (steve_at_nospamtnccreations.com)
Date: 02/28/04
- Next message: Larry Rekow: "Re: Is there a better way?"
- Previous message: MD Websunlimited: "Re: Is there a better way?"
- In reply to: MD Websunlimited: "Re: conditional javascript script"
- Next in thread: MD Websunlimited: "Re: conditional javascript script"
- Reply: MD Websunlimited: "Re: conditional javascript script"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 28 Feb 2004 15:04:01 -0600
Thanks Mike..this is a big help
Steve G
"MD Websunlimited" <none@none.com> wrote in message
news:OqTqEqj$DHA.3712@tk2msftngp13.phx.gbl...
> Steve,
>
> That code will not work as the include needs to be process at the server
and JavaScript is client side.
>
> To accomplish create two script files that write out the code using
document.write statements. Next, use the conditional JavaScript
> source that was shown before to src the included script.
>
> To recap you'd have two file of script:
> vert_nav.js and hor_nav.js
>
> Then the page would contain:
>
> <script language="Javascript" type="text/javascript" >
> if (screen.width <= 600) {
> document.write('<script src="side_nav/vert_nav.js" type="text/javascript"
>');
> }
> else {
> document.write('<script src="side_nav/hor_nav.js"
type="text/javascript" >\n');
> }
> document.write('</script>');
> </script>
>
>
> In J-Bots we use a technique to allow browser independance while allowing
ease of program. To accomplish this we use function
> overlays that bring in code based upon the browser. This is the code that
we use:
>
> var oBrowser=new checkBrowser();
>
> // load the browser specific code Why does this work?
> if(oBrowser.ns4) {
> document.write("<script language=\"JavaScript1.2\" src=\"" + sWUScripts
+ "_WUScripts/ns4obj.js\" >\n</" + "script>");
> } else {
> document.write("<script language=\"JavaScript\" src=\"" + sWUScripts +
"_WUScripts/ieobj.js\" >\n</" + "script>");
> }
>
> if (oBrowser.ns5){
> document.write("<script language=\"JavaScript\" src=\"" + sWUScripts +
"_WUScripts/ns5obj.js\" >\n</" + "script>");
> }
>
>
> HTH,
>
> --
> Mike -- FrontPage MVP '09 - '02
> http://www.websunlimited.com
>
>
>
>
> "Steve" <steve@nospamtnccreations.com> wrote in message
news:euL46dh$DHA.2524@TK2MSFTNGP10.phx.gbl...
> > Thanks for the responses, guys, unfortunately, I can't seem to get this
> > stuff to do what I want. Maybe a bit more explanation will help.
> >
> > I am trying to set up this site so that it will pull different elements
into
> > a page based on screen resolution. For instance, I have two style
sheets,
> > one based on a screen resolution of 800 X 600, another one based on
higher
> > resolutions, to set text sizes and some other things. This is working
well.
> >
> > Now I need to pull in navigational stuff again based on resolution.
Nomally
> > I would just use an include file to do this such as:
> > <!-- Include file="something.htm" --> but in this instance I need to
base it
> > on screen resolution. And rather than an html file, I was trying to pull
in
> > the script instead. Since I can't seem to get that to work, I tried this
> > instead:
> >
> > <script language="Javascript" type="text/javascript">
> > if (screen.width <= 600) {
> > document.write('<!-- #Include file=side_nav/side_nav.html -->');
> > }
> > else {
> > document.write('<!-- #Include file=vert_nav1/vert_nav1.html -->');
> > }
> > </script>
> >
> > I believe I could do this pretty easily using ASP and VB, but in this
> > instance, I would prefer to use javascript and html.
> >
> > However, although I do not get any script errors, this is not working.
Am I
> > simply trying to do something that is not possible?
> >
> > TIA
> >
> > Steve G
> >
> > "Steve" <steve@nospamtnccreations.com> wrote in message
> > news:uHf1Cna$DHA.2660@TK2MSFTNGP10.phx.gbl...
> > > Hi All...
> > >
> > > Got a question regarding javascript.
> > >
> > > I am trying to use javascript to call a navigational bar based on
screen
> > > resolution:
> > >
> > > <script language="Javascript" type="text/javascript"
> > > if (screen.width <= 600) {
> > > src="side_nav/side_nav.js"
> > > }
> > > else {
> > > src="vert_nav1/vert_nav1.js"
> > > }>
> > > </script>
> > >
> > > This is not working...soooo...anyone got any ideas as to why? I sure
would
> > > appreciate some help here.
> > >
> > > TIA
> > >
> > > Steve G
> > >
> > >
> >
> >
>
>
- Next message: Larry Rekow: "Re: Is there a better way?"
- Previous message: MD Websunlimited: "Re: Is there a better way?"
- In reply to: MD Websunlimited: "Re: conditional javascript script"
- Next in thread: MD Websunlimited: "Re: conditional javascript script"
- Reply: MD Websunlimited: "Re: conditional javascript script"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|