SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    weird spacing issue from script tag

    I'm working on a site that uses a javascript tag like...

    <script language="javascript" src="../Scripts/vert_menu.js"></script>

    On the pages that use this particular tag, there are no problems. But, when I use the same tag like

    <script language="javascript" src="Scripts/vert_menu.js"></script>

    on pages in the root directory, it's throwing a space about 75 pixels at the top of the page. This only happens in IE. The path is correct, so that's not the issue, but I can't seem to find any other reason for it. When I take this tag out, the space goes away. I double checked the javascript file and there's nothing in there that should create the space. Anyone ever seen this action in IE before and have an idea on what to do? Thanks.

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Strange! Try:
    Code:
    <script type="text/javascript" src="./scripts/vert_menu.js"></script>

  3. #3
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, that didn't do anything.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Probably a new line character following the code being interpreted as a space.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Zealot solutionsphp's Avatar
    Join Date
    Jun 2005
    Location
    Denman Island, BC, Canada
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just had this problem as well... a script tag with tracking code placed just before the closing BODY tag resulted in unwanted space in IE. To remedy, I wrapped the script code in a DIV, then assigned that a margin-top of -12px (the height of the unwanted white space). Did the trick for me, hope this helps someone in the same boat.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If it is in the <head> of the page then it shouldn't be affecting the page layout at all. If it is in the <body> then it would have to be either the spacing around the script or something in a document.write() within the script that is affecting the layout.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about ./Scripts~? (though that is the gist of Mr. Bradley's suggestion)

    Also, make sure there aren't any extraneous characters in the head. Something like a period at the end of a line, which might not be easy to see, can create an unwanted character in the page.

  8. #8
    SitePoint Zealot solutionsphp's Avatar
    Join Date
    Jun 2005
    Location
    Denman Island, BC, Canada
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The script was in the BODY, white space in the code not an issue. The document.write echoes a 1x1 pixel gif, but IE expands that space to about 15 px high.

  9. #9
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure IE finds the path to the image? If not and no width and height are set, then it will expand to the default "not found" image

  10. #10
    SitePoint Zealot solutionsphp's Avatar
    Join Date
    Jun 2005
    Location
    Denman Island, BC, Canada
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Width and height are set. The image is called in this manner:

    cgi-bin/script.pl?trans.gif

    IE is resolving correctly because I can see hits to that image from IE in my logs.

    No biggie really, I have it resolved visually, though I'm not a fan of mysteries.

  11. #11
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But a border around the image, then you will be able to spot it, then right click and copy the path. Paste it into the URL bar, does it load?


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
  •