Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help getting two different funcion scripts withinin <HEAD> to operate

    Howdy. I am primarily an artist/graphic designer with a severe tech bent, and I've been working/searching in vain for a way to get a client's website to contain: (1)a browser detect and "document.write('<link rel>)" function for its respective stylesheets, and, (2)the preload/swapImage script for its mouseover images within the <Head> elements--and have both of them function. The books I have place both these functions inside the <Head> elements (with the "onLoad" and "OnMouse-x" stuff within the Body), but I can find nothing that tells me how to get these guys to play together without one of 'em biting the dust..
    The mouseover stuff is Dreamweaver 4's, and the browser detect is a combo from the "Teach Yourself Javascript in 24 hours" & the Osborne 3rd HTML Reference books. I feel like I'm probably missing a basic solution, but I sure haven't found it....Am I wanting the impossible?

    I would appreciate any understanding you guys might be able to impart--am having difficulty finding any in either book...

    THX
    Last edited by WebKunstler; 07-28-2002 at 06:23 AM.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks for your answer, A1ien51

    I'd read that link prior to posting my question, but reread it completely--along with some other links I'd bookmarked from WebMomkey in hopes I'd missed something. Those scripts don't have an "OnLoad" furhter down in the Body--just the <span class="_"> tags (if necessary) at the appropriate points in copy.

    Maybe I should create an "OnLoad"? I'll try that later this am--gettin' bleary-eyed.

    oh--like your "location". cool.

  • #4
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    can we see the code you're working with? would make it easier for us to help you figure out where the problem is.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #5
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    the code

    thanks,joh6nn. here's the browser detect/writeStyles script:

    <script language="JavaScript">
    <!--
    function writeStyles()
    {
    if ((navigator.appVersion.charAt(0) >= "4")
    || (navigator.appVerions.charAt(0) >= "5")) {
    if (navigator.appName == "Netscape")
    browser="netscape";
    else if (navigator.appName=="Microsoft Internet Explorer")
    browser="ie";
    else alert("This site requires a 4.0 or later browser.");
    }
    if (browser=="ie") {
    document.write('<link rel="stylesheet" type="text/css" href="iestyle.css">');
    }
    if (browser=="netscape") {
    document.write('<link rel="stylesheet" type="text/css" href="netstyle.css">');
    }
    //-->
    </script>

    there's no "onload" reference to this script within the <BODY> tags; just <span> elements where needed...

    was working fine (with <link rel> line in the head) til i saw how differently the browsers interp'ed the pixel sizes and decided i wanted them to look as similar as possible...(yeah, i know, "stupid designer!")
    Last edited by WebKunstler; 07-28-2002 at 01:39 PM.

  • #6
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2nd Re to joh6nn: see sample html

    just realized i could attach one of the pages resaved as text file--Been at it a little too long/gettin sloppy...

    tried various ways to marry the first function to the following original page (and similar),+ 2 stylesheets to have just one site: A) as 2 separate functions within <script> tags; B) using a "<script src>" line with corresponding .js files & folder; C) combining the 2 functions coupled with changing their order--not smart when really tired & frustrated; D) variations of the aforementioned, and other desperate measures that make me realize i'm trying to teach myself too many things too quickly...

    I've used simpler mouseover/preload code before, but I've had no probs with Dreamwvr code + some hand editing til now...

    Seems needless to make separate sites, but been lookin at it too long to see clearly now

    thanks!
    Attached Files Attached Files
    Last edited by WebKunstler; 07-28-2002 at 01:53 PM.

  • #7
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    i made a couple of changes to your code, mostly just adding { }'s to your if-else clauses, to make it easier to read. i also added a line that actually calls your function, because that didn't seem to be present. if you still have problems, i'd say to post a link to the site, or attach a file with all the code in it, so we can get a look at the whole page.

    i know that there's a way to do a sort of browser detect within a style sheet ( it relies upon the peculiarities of browsers ), but i'm not real familiar with it. here's an article on the subject:
    http://www.evolt.org/article/Assigni...732/index.html

    good luck.


    ps: are you in germany?
    Last edited by joh6nn; 07-29-2002 at 05:25 AM.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #8
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks,joh6nn..

    i read through your reply, but couldn't find a file with the changes you talked about anywhere (my original browser-detect post looks the same as the copy on my hard drive)...would you mind posting it in another reply so I could see how you did what you did, and see how it works?
    i am grateful for the trouble you've taken to reply--this has really had me going; and shown me that i'm gonna have to take a little more time with this. Learning on the fly and against deadline just ain't cuttin' it!

    And, no, i'm not in germany, but the U.S.— Memphis, TN, at present, but not for much longer. As to my German username, i was born in Germany and i'm Greek American....(!)

  • #9
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    sorry, thought i posted it, but i must've forgotten. here you go:

    <script language="JavaScript"> <!--
    function writeStyles() {
    var style;
    if ((navigator.appVersion.charAt(0) >= "4") || (navigator.appVerions.charAt(0) >= "5")) {
    if (navigator.appName == "Netscape") {
    style = "netstyle.css";
    }
    else if (navigator.appName=="Microsoft Internet Explorer") {
    style = "iestyle.css";
    }
    else {
    alert("This site requires a 4.0 or later browser.");
    }
    }
    document.write('<link rel="stylesheet" type="text/css" href="' + style + '">');
    }
    //-->
    </script>


    i suggest you take a look at the article i linked to; it's probably a better solution to this.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #10
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks again, man.

    i took a look at that article last night as soon as i read your reply post, but had too bookmark it so i could read with a rested brain--even then it did look like a better solution. i'll probably try to get these two scripts working together anyway just to find out what i wasn't doing --or doing wrong.

    if you like, i'll post a link to my site when i've got it back up--kinda proud of it

    WK


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •