SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    best practice for <% %> snippet that set display for a query ?o=1

    I want the product pages on my site to not look like poop on IE7 / 8 / 9.

    I discovered today, that while I had tested site ~2008 / 2009 in IE7 and it was working, now IE 8 / 9 goes to quirks mode. Though I haven't changed anything. From research I believe it is because some of the <% %> snippet was written before the <!DOCTYPE>

    So....

    Where is best practice for placing the
    Code:
    <!-- include=””-->
    <% Dim tab1, tab5, switchtabs
        switchtabs = Trim(request.querystring("o"))
        if isnumeric(switchtabs) then
            tab1="style='display:none'"
            tab5="style='display:block'"
        else
            tab1="style='display:block'"
            tab5="style='display:none'"
    end if %>
    After <html> but before the <head>,
    in the <head></head>
    first thing in the <body></body> other ideas?

    From research today and experimentation, it seems that removing a classic .asp snippet and include from before

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    allows it to display correctly in IE 7 /8 /9 but leaves for me the question of where to put the snippet that calls a particular portion of page to display

    Code:
    <!--#include file="store/pc/include-metatags.asp"-->
    
    <!-- 'default to order tab or not -->
    <% Dim tab1, tab5, switchtabs
        switchtabs = Trim(request.querystring("o"))
        if isnumeric(switchtabs) then
            tab1="style='display:none'"
            tab5="style='display:block'"
        else
            tab1="style='display:block'"
            tab5="style='display:none'"
    end if %>
    My situation:

    classic asp
    site is hosted on Windows Server 2003 Microsoft-IIS/6.0 All of the page files are .asp the site was designed / built by an agency. I push the pieces around. Yet it seemed that it was working on my test of ie 6 / 7. It seems to default to quirks mode in ie9, presently

    Presently code that breaks in IE 7/8/9 looks like this:
    Code:
    <!--#include file="store/pc/include-metatags.asp"-->
    
    <!-- 'default to order tab or not -->
     <% Dim tab1, tab5, switchtabs
        switchtabs = Trim(request.querystring("o"))
        if isnumeric(switchtabs) then
            tab1="style='display:none'"
            tab5="style='display:block'"
        else
            tab1="style='display:block'"
            tab5="style='display:none'"
    end if %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        </head>
        <body>
        <!-- sample for stackoverflow -->
            <div class="scontentsub">
                <div id="leftcolprod">
                    <h5>Hello</h5><img src=”big-product.jpg”>
                </div>
                <div id="rightcolprod">
                    <div class="models_container" id='tab1' <%=tab1%>>
                        <h4>features</h4>
                    </div>
                    <div class="models_container" id='tab5' <%=tab5%>>
                        <h4>Order Now</h4>
                    </div>
                </div>
            </div>
        </body>
    </html>
    What I have researched:

    I read ~6+ stackoverflows on IE 7 / 8/ 9 quirks mode and found the initially correction of pulling anything from before the <!DOCTYPE html> out of the file. I also experimented with, what I read on one Q&A,
    Code:
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    , and while I got IE to render correctly the layout, I wasn't certain it was a best practice from what I was readoing.

    I also read but did not try but this may be relevant with my server question try doing this other response I found,

    Code:
    Response.AddHeader "X-UA-Compatible", "IE=edge,chrome=1"
    My experimentation were working in IE 9 and not defaulting to quirks mode when I inspected in the developers tool:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        </head>
        <body>
        <!-- sample for stackoverflow -->
            <div class="scontentsub">
                <div id="leftcolprod">
                    <h5>Hello</h5><img src=”big-product.jpg”>
                </div>
                <div id="rightcolprod">
                    <div class="models_container" id='tab1' <%=tab1%>>
                        <h4>features</h4>
                    </div>
                    <div class="models_container" id='tab5' <%=tab5%>>
                        <h4>Order Now</h4>
                    </div>
                </div>
            </div>
        </body>
    </html>

    After experimenting with pulling any text that is before <!DOCTYPE> I began to wonder what is best practice on where to place a operation that renders pages uniquely based on inbound link query. To answer this I read another half-dozen stackoverflow post / sitepoint forums / reviewed w3schools.com / asp intro through a few segments (which I had read previously)

    Question restated:

    Where is best practice for placing the

    <!-- include=””-->
    and

    <!-- 'default to order tab or not -->

    After <html> but before the <head>,
    in the <head></head>
    first thing in the <body></body> other ideas?

    Thanks Casey enthusiast / learner

  2. #2
    SitePoint Zealot gidday's Avatar
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Casey
    Doctype at the top of the page. No question about that. I place my includes directly below that line.
    As to <!-- 'default to order tab or not --> my response would be to put it after the includes.
    Joe
    "All that is necessary for the triumph of evil
    is that good men do nothing."

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks everyone...

    I need the HTML <!Doctype ... > to be read first. But the comment was in HTML format...

    there was a mix up on the comment... if it was left 'default to order tab or not that would be read on server and not HTML.... so I pulled the HTML comment <!-- --> off and things seem to be working great.


    Quote Originally Posted by gidday View Post
    Hi Casey
    Doctype at the top of the page. No question about that. I place my includes directly below that line.
    As to <!-- 'default to order tab or not --> my response would be to put it after the includes.

  4. #4
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    359
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Includes happen on the web server. DOCTYPE is html in the browser. Your includes need to be above any HTML such as DOCTYPE if you plan on doing any server-side response.redirects or cookies work in the included server code. The first bit of HTML will write the html headers out to the browser and things like redirect will not work after the headers are written.

    Remember that whatever code is in the included file(s) will execute on the server as if all the included code were typed in the original page at the point of the include.
    Doug G
    =====
    "If you ain't the lead dog, the view is always the same - Anon


Tags for this Thread

Bookmarks

Posting Permissions

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