Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Embed script in Header pushing down body content

  • 30-03-2010 03: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, Registered Users 2 Posts: 490 ✭✭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, Registered Users 2 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, Registered Users 2 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: 9,206 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: 9,206 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