Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Embed script in Header pushing down body content

Options
  • 30-03-2010 3:32am
    #1
    Closed Accounts Posts: 602 ✭✭✭


    I have this in the <Head> tag:
    <script language=javascript>
    <!--
    var sound1="sound18.swf"
    if (navigator.appName=="Microsoft Internet Explorer")
    document.write('<bgsound src='+'"'+sound1+'"'+' loop="false">')
    else
    document.write('<embed src='+'"'+sound1+'"'+'hidden="true" border="0" width="0" height="0" autostart="true" loop="false">')
    //-->
    </script>
    
    It's causing the page content to be pushed down by about 10px from the top in both Firefox and IE. Can I prevent this from happening?


Comments

  • Registered Users Posts: 489 ✭✭Pablod


    This is probably better suited in the Design Forum,

    Anyway, if its a hidden script if shouldn't effect the position of your content.

    Check the Margins & Padding on your Header & Content sections these could be whats causing a gap, they may need to be zeroed out.


  • Registered Users Posts: 2,119 ✭✭✭p


    Of course it is, this is what you're actually doing. You can't put HTML code in the head.

    <htmll>
    <head>
    <embed src="sound18.swf" hidden="true" border="0" width="0" height="0" autostart="true" loop="false">
    </head>
    <body>
    </body>
    </html>


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    <html>
    <head>
    </head>
    <body>
    <embed src="sound18.swf" hidden="true" border="0" [B]style="display:none;"[/B] autostart="true" loop="false">
    </body>
    </html>
    

    Is a possible solution. Anyway, I'm moving this over to Design (from Development).

    Sound in a web page though, do you really have too? Bleargh, tbh.


  • Moderators, Science, Health & Environment Moderators Posts: 8,865 Mod ✭✭✭✭mewso


    As has been said. If you absolutely have to then just move the script to the end of the document before the closing body element or if you must keep it in the head then don't use document.write, append the stuff to an existing element on the page and do it on window.load.


  • Closed Accounts Posts: 602 ✭✭✭eman66


    OK, it doesn't affect the content in an otherwise empty table cell or at the end of the page as recommended.

    This is what I'm trying to achieve..

    Two short sound-only flash files played simultaneously lilke this (Firefox only): Sound Test

    Two <embed> tags in Firefox, short and simple, works. But the <bgsound> tag in IE doesn't work in the same way. Any ideas as to how it can be done in IE?

    EDIT: hmmmmmmm! Seems to be working in IE8.. using the <embed> tag. /scratches head!


  • Advertisement
  • Moderators, Science, Health & Environment Moderators Posts: 8,865 Mod ✭✭✭✭mewso


    I think it might be worth considering something like the jplayer which used with jquery will cover most of the cross browser issues for you. Be wary of outdated scripts out there. You see a lot of it posted here. Some tips are if a script includes any of the following it's outdated:-

    document.write
    document.all
    navigator.appname
    window.open
    window.showmodaldialog
    MM_preloadImages
    MM_swapImage

    The MM stuff is god-awful dreamweaver auto-scripts if memory serves. All of the above are from the late 90s in a lot of cases and still copied and pasted from google searches. While I stopped using Dreamweaver a long time ago I would hope it has stopped using those horrible scripts. We all want to learn but seriously have a look at jQuery. It really is as good as people say it is.


Advertisement