Redirect Q

Discussion in 'Computer Information' started by Paul, Mar 23, 2014.

  1. Paul

    Paul Guest

    You should really be in a web authoring or HTML
    programming group for this, to tap into experts.
    There aren't going to be enough of those programmers
    here, to answer all questions.

    The way I look at it, the <body></body>
    and <head></head> are two separate portions
    of the web page, with different purposes. You
    would not expect all the same capabilities to
    exist in both. Do you know for a fact, that
    head and body support all the same programming
    constructs ? I don't know the answer to that.

    The definition of the location.replace is here...

    http://www.w3schools.com/jsref/met_loc_replace.asp

    and there are a few examples of HTML usage here.

    http://www.w3schools.com/html/html_examples.asp

    On that last page, look at the three examples for
    some idea of what goes in the <head> section.
    It doesn't look like a lot of "programming" goes
    in there.

    HTML head Elements
    ------------------

    Specify a title for a document
    One default URL and target for all links on a page
    Provide metadata for a document

    HTH,
    Paul
     
    Paul, Mar 23, 2014
    #1
    1. Advertisements

  2. Paul

    Robert Baer Guest

    The following stupid snippet works:
    <body>
    <script>
    if (true)
    { location.replace('PCbase.html'); }
    endif
    </script>
    </body>

    But what i want is:
    <head>
    <script>
    if (true)
    { location.replace('PCbase.html'); }
    endif
    </script>
    </head>

    What code IN HEAD section will replace/"jump"?
     
    Robert Baer, Mar 23, 2014
    #2
    1. Advertisements

  3. Paul

    Robert Baer Guest

    OK: will hunt for one.
    Found a way to "do it all" in the body, as follows:

    <script>
    // discover if browser is crappy Opera or crappy Safari
    str=navigator.userAgent; // Agent is unique for our purposes
    var sf=str.indexOf("Safari"); // found if browser is Chrome or Safari
    var ch=str.indexOf("Chrome"); // not found if browser is Safari
    var op=str.indexOf("Opera"); // unique for Opera
    var opt=1; // alternate shown below but not used
    ovar=window.opera; // is undefined if browser is not Opera
    if (!ovar) { opt=-1; } // unique for Opera
    // Safari gives sf=91,ch=-1; Opera gives sf=-1,op=7; Chrome gives
    sf=-1,ch>0.
    // Jump to different markup if crappy browser
    if (sf>0 && ch<0 || op>=0) { window.location.replace('Mobile.html'); }
    // ** NOTE treat crap as if mobile phone **
    // Code is a one-pager; there are mobile phones that struggle and die with
    // message "Page too large" "open media site"

    var isIE=str.indexOf("IE"); // not found in other browsers
    if (isIE>0) { window.location.replace('PCbase.html'); }
    var isMozilla=str.indexOf("Mozilla"); // Presumes in all variants;
    includes Netscape
    if (isMozilla>=0) { window.location.replace('PCbase.html'); }
    if (ch>=0) { window.location.replace('PCbase.html'); } // for Chrome

    document.write(str+"<BR>");
    document.write("At this point, browser is not Safari, Chrome, Opera or
    IE or Mozilla"+"<BR>");
    // So, ASSuME we have mobile phone browser
    // window.location.replace('Mobile.html');
    // -----^ always executes; previous valid .replace somehow bypassed
    </script>

    Above works fine, except as noted.
    NOT TESTED on a mobile phone (yet).
     
    Robert Baer, Mar 24, 2014
    #3
  4. Paul

    Paul Guest

    But, are all the browsers honest ?

    http://www.nczonline.net/blog/2013/07/02/internet-explorer-11-dont-call-me-ie/

    *******

    Make sure you're getting the best from your search engine. Since every web
    developer will have done this stuff at one time or another, there will be
    some "best practices" thoughts out there.

    https://developer.mozilla.org/en-US/docs/Browser_Detection_and_Cross_Browser_Support

    http://stackoverflow.com/questions/1005153/auto-detect-mobile-browser-via-user-agent

    http://detectmobilebrowsers.com/

    There's client or server sniffing, object or useragent determination.
    More than one way to get there.

    HTH,
    Paul
     
    Paul, Mar 24, 2014
    #4
  5. Paul

    Robert Baer Guest

    Thanks; i had read somewhere that 'location.replace' was preferred.
    Will change them back.

    Me two:).
    I just dabble in HTML to the extent of experimenting to figure out
    how to get it to work how I want. I am not an HTML guru.
    I finally figured out how to what i want with all code in the body.
     
    Robert Baer, Mar 24, 2014
    #5
  6. Paul

    Robert Baer Guest

    "But, are all the browsers honest ?"
    Answer has been "NO" since the daze of Android mobile phones, where
    the navigator.userAgent string may be almost anything.

    Those other references are interesting, and it willtake me a while to
    digest the info.
    Thanks!
     
    Robert Baer, Mar 24, 2014
    #6
  7. Paul

    TeeJay1952 Guest

    I feel like you guys just saved the nanobots on Revolution!
    Tee Jay
     
    TeeJay1952, Mar 24, 2014
    #7
  8. Paul

    Paul Guest

    See how easy web design is ?

    Get yourself a browser with a Composer window, and you
    can try stuff out for yourself. Seamonkey has a Composer window.

    http://www.seamonkey-project.org/

    Copy this into the Composer window while in source mode.
    (Click the "Source" tab at the bottom of the Composer window first.)
    And then you can view what it will look like as a web page.
    After you paste this in, try clicking the "Preview" tab to see
    what it looks like. What the code does.

    ------------------------------------------------------------------------
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    <title>Hello World!</title>
    </head>

    <body>
    <p>Hello World!
    </p>

    <p>Huh, <em>that's</em> not so tough. Now let's try something else.
    </p>
    </body>
    </html>
    ------------------------------------------------------------------------

    One thing I notice, is when I click the Source tab, to go back so
    I can do some more edits, it ruins my nice indenting. Guess it wants
    tabs or something.

    If an employer asks you what kind of web design experience
    you have, you can say "I designed Hello World!" :)

    Have fun,
    Paul
     
    Paul, Mar 24, 2014
    #8
  9. Paul

    Guest

    On 25/03/14 02:28, Paul wrote:

    In my SeaMonkey Composer, when I go back to the Source tab, it's still
    indented.

    Daniel
     
    , Mar 26, 2014
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.