SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  1. #1
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Netscape 4.x and CSI

    I am creating a site that will use a Client-Side Include (CSI) to dynamically generate an ad banner to be placed on the right hand side of the page. It loads great in IE5 and above and Netscape 7 and even loads fine in Netscape 4.7. The problem is when the user resizes the window, the ad banner that was generated is then placed at the bottom of the page. I even look at the HTML of that particular page and the CSI is thrown into the bottom portion of the site. I am perplexed as to how it just throws it down AND knows where in the HTML code to insert itself.

    If anyone has any ideas on how to stop this snippet of code placing itself anywhere in the site, I would appreciate any help. Again, it LOADs fine but when the user decides to re-size the window, it just moves it down to the bottom of the site. Any help would be appreciated.

    - Brian Russell

  2. #2
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    top

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What browser does the problem occur with?

    Give us a link to the page and we'll take a look at it.

    edit...

    Ok, I just woke up. Your thread title implies that the problem is with NN4. Do you know about the resize issue with NN4? (you have to reload the page if you're doing any kind of js positioning) - and you can't trust the resize event you have to roll your own.

  4. #4
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MikeFoster
    What browser does the problem occur with?

    Give us a link to the page and we'll take a look at it.

    edit...

    Ok, I just woke up. Your thread title implies that the problem is with NN4. Do you know about the resize issue with NN4? (you have to reload the page if you're doing any kind of js positioning) - and you can't trust the resize event you have to roll your own.
    I am aware of the re-size problem but only a little bit. I came across that problem while doing research for this problem. So what do you mean by "roll your own?"

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what do you mean by "roll your own?"


    For NN4 you need to simulate the window onresize and onscroll events - so you don't have to worry about the browser quirks. This is a simple example but should convey the concept. Use the same technique for simulating the window scroll event.
    Code:
    <html>
    <head>
    <script type='text/javascript'>
    var nn4_prev_width, nn4_prev_height, is_nn4 = false;
    window.onload = function()
    {
      addWinResizeListener(winOnResize);
    }  
    function addWinResizeListener(fnListener)
    {
      if (window.addEventListener) {
        window.addEventListener('resize', fnListener, false);
      }
      else if (window.attachEvent) {
        window.attachEvent('onresize', fnListener);
      }
      else if (document.layers && typeof(window.innerWidth) != 'undefined') {
        nn4_prev_width = window.innerWidth;
        nn4_prev_height = window.innerHeight;
        is_nn4 = true;
        setTimeout("simResizeEvent()", 500);
      }
      else {
        window.onresize = fnListener;
      }
    }
    function simResizeEvent()
    {
      if (window.innerWidth != nn4_prev_width || window.innerHeight != nn4_prev_height) {
        winOnResize();
      }
      else setTimeout("simResizeEvent()", 500);
    }
    function winOnResize()
    {
      if (is_nn4) history.go(0);
      else {
        // ...
      }
    }
    </script>
    </head>
    <body>
    <h1>NN4 window onresize event example</h1>
    </body>
    </html>

  6. #6
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MikeFoster


    For NN4 you need to simulate the window onresize and onscroll events - so you don't have to worry about the browser quirks. This is a simple example but should convey the concept. Use the same technique for simulating the window scroll event.
    Upon talking to my team, the problem seems to lie in our "document.writeln" in the CSI. As I said, the page loads the first time in NN4 fine but when refreshed, it inserts the "document.writeln" in wherever it so chooses. Will this code you gave me prevent the browswer from inserting the code wherever upon refresh AND still give the user the ability to resize the window?

    I noticed in the code there is a comment in your last "else" statement. I'm assuming I'm supposed to put code there right?

    Thanks for all you've done so far, you've taken time out of your day to reply to my messages and I appreciate that. Thank you.

    - Brian

  7. #7
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Will this code you gave me prevent the browswer from inserting the code wherever upon refresh AND still give the user the ability to resize the window?
    Without seeing your page (or a post of the relevant code) I can only guess.
    I noticed in the code there is a comment in your last "else" statement. I'm assuming I'm supposed to put code there right?
    Yes, whatever you want to happen onresize for non-nn4 browsers.
    Thanks for all you've done so far, you've taken time out of your day to reply to my messages and I appreciate that. Thank you.
    You're very welcome

  8. #8
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't post the code for it is on another network but I can kind of give you an idea of what is going on.

    Code:
    <table>
      <tr>
        <td>Search Results</td>
        <td>Client-Side Include</td>
      </tr>
    <table>
    It's a simple table really and on the left hand side, search results are generated and displayed and on the right hand column, I have an ad banner, which is the CSI. Now again, when the site is initially loaded in the browser, it loads in the correct <td> tags, but when you re-size the browser, the CSI that is supposed to go between the second <td> tag is now inserted down towards the bottom of the page before my footer.

    Does that make sense?

  9. #9
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    NN4 does weird things with positioned elements on window resize - you can get all kinds of symptoms. Are you reloading the page on resize? Are you using the resize event or simulating it?

  10. #10
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The page reloads the page automatically when the user tries to resize the page. We're not using the resize event, we're just doing it outselves. Hmm...I'm really not sure how else to go about doing this.

    We want to use a CSI because we have to use .html instead of a dynamic language like .ASP or something. The easiest scenario would be to use SSI and call it game but we have to use .html for this particular file and CSI is just about all we can do. Someone said something about maybe defining the function in <head> but I didn't quite listen to what he was saying so I didn't catch it all. Do you know of any other way to accomplish what I'm trying to do? Any suggestions would be appreciated.

  11. #11
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The page reloads the page automatically when the user tries to resize the page. We're not using the resize event, we're just doing it outselves.
    Exactly how and when do you make the decision to reload the page? Post the relevant code.
    Do you know of any other way to accomplish what I'm trying to do?
    I don't even know how your currently doing it. Post the relevant code.

    If the page is truely being reloaded after the final resize then it should display the same as it did the first time it was loaded.

    Talk to your team and see if they will put the page online temporarily.

  12. #12
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apologies for butting in.

    What's a CSI? You mention it as if that was a commonly used term (like SSI). I've seen it used, but just as a (contrived) term of convenience for a so-called 'JavaScript include'. This:
    I even look at the HTML of that particular page and the CSI is thrown into the bottom portion of the site.
    ...is odd, as HTML output dynamically (with JS) never appears in source code, since the JS which generates it is actually the source. You sound as if you're talking about a server-generated document fragment - but, then again, you disallowed that....not that Mike F. needs any assistance, but I think he's asking you, as politely as possible:

    ::: certified wild guess :::

  13. #13
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok...sorry for the confusion, it's just this is baffling me and I'm trying to find ways to explain it as best as possible. So I'm gonna try and do so the best I can...

    Picture this. You have a table seperated into two columns; the left side being your search results from the query you entered on the previous page. The right side has two tables that basically advertise products our company produces. So basically, the .html is as follows...

    Code:
    <table>
      <tr>
        <td>Search Results</td>
        <td><script type="text/javascript" src="adbanner.js"></script></td>
      </tr>
    <table>
    Here is what my adbanner.js looks like...

    Code:
    function b(s) {
        document.writeln(s);
    }
    
    b('<style type="text/css">');
    b('.banner_ad { ');
    b('    border: 2px solid #CCC;');
    b('}');
    b('<table cellpadding="2" cellspacing="5" border="0">');
    b('<tr><td>');
    b('<p><a href="http://www.espn.com" target="_blank">ESPN</a></p>');
    b('</td></tr>');
    b('</table>');
    Now this is a condensed version of course, but you get the idea. When the page is loaded in Netscape 7 or any IE, it's fine. But when loaded in NN4, it gives me problems. On the original load, it inserts this table in between the correct <td> tag from the first code block. However, when the user resizes the window, this .js script is inserted towards the bottom of the page. I say CSI because it acts like a Client Side Include but I know there is no such thing.

    Does this make sense?

  14. #14
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    Quote Originally Posted by adios
    Apologies for butting in.
    You can jump in anytime, dude

    Quote Originally Posted by adios
    What's a CSI?
    I never watch TV


    Brian, man, you're really being stingy with the code, eh?

    Oh I bet NN4 doesn't like that style element stuck in the body (NN4 is a cranky old man ). Never mind the fact that there's no closing tag. But then, you did say "this is a condensed version" so I'm probably wasting my time looking at that snippet.

    Quote Originally Posted by MikeFoster
    Exactly how and when do you make the decision to reload the page? Post the relevant code.

  15. #15
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never watch TV...
    My thought exactly ! ###
    ::: certified wild guess :::

  16. #16
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We're havin too much fun! Somebody stop us!!!

    Edit:

    wipe that smile off your face Foster, you're supposed to be takin a break


    oh yeah

  17. #17
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haha...

    I'm sorry if I keep confusing you. To answer the "exactly how and why" question...the how is netscape does it on it's own. I like to have my browser window the full size of the screen but when you click the minimize button, it then automatically refreshes the window and bam, the code is randomly inserted.

    You're not wasting your time looking at the snippet. I condensed it by not including all of my CSS for the table. You can see the outline of the table that is supposed to go in the <td> tag from the table above. I will try and take out the style tag and see what it does.

    Again, I'm probably confusing everyone on this site because this seems to be a unique question I'm posing here. I haven't found anything that describes this problem.

  18. #18
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not a unique question at all. You won't show us the code so how are we supposed to fix it?

    To answer the "exactly how and why" question...the how is netscape does it on it's own.
    Ah ha! So the answer finally comes out I've already posted the code for your solution Oh man, I really do need to go take that break...

  19. #19
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You posted the code that dis-allows the user from resizing the window correct? We still want our users to resize the window. Maybe I mis-read the code then...hmmm....


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
  •