Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Positioning in javascript document.write("<... Help! please

    Hi!
    I don't know much about javascripts but hope to get some help:
    I have this code:
    PHP Code:
    {document.write("<embed name='midi' src="+mide+" loop='1' autostart='true' hidden='false' width='300' height='100'>")} 
    I want to define a position for this object on the screen. How and where can I put a position? I have tried with document.left=400 or document.style.left=400, NO luck.

    Thanks for your help.
    mx-guest2004

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Just put that wherever you want the player to be displayed. But if you want it exactly at 400x400 position, you can put it in a absolutely positioned div.

    <div style="position:absolute;left:400px;top:400px;">
    <script type="text/javascript">
    document.write('<embed name="midi" src="'+mide+'" loop="1" autostart="true" hidden="false" width="300" height="100">');
    </script>
    </div>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    If static positioning, use CSS

    <div style="position:absolute;left:200;top:200">
    <script>.....</script>
    </div>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New Coder
    Join Date
    Jun 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks glenngv and kor;
    This document.write... is in a function and activates by a function call. If the condition is true, then it writes.
    Can I put glenngv's code in that function? Where?
    I have:
    <script>
    function()
    ..
    ..
    document.write...
    </script>

    mx-guest2004

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    than use

    <script type="text/javascript">
    document.write('<div style="position:absolute;left:200;top:200"><embed name="midi" src="'+mide+'" loop="1" autostart="true" hidden="false" width="300" height="100"></div>');
    </script>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    New Coder
    Join Date
    Jun 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Kor,
    Sorry I ask this stupid question:
    My script begins with <script language="Javascript">
    I put your last code between as this but it didn't work. Whta did I do wrong?

    mx-guest2004

    <script language="Javascript">
    function()
    ...
    <script type="text/javascript">
    document.write('<div style="position:absolute;left:200;top:200"><embed name="midi" src="'+mide+'" loop="1" autostart="true" hidden="false" width="300" height="100"></div>');
    </script>
    </script>

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts

    No nested <script> tags

    You can't put <script> tag within another <script> tag. You only need one.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    New Coder
    Join Date
    Jun 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It doesn't work with <script type="text/javascript> neither.
    I put the whole code here and I hope it helps to see the whole:
    It works without positioning and the device appears in the left corner of the screen, if the condition is true.

    <html>
    <head>
    <script type="text/javascript>

    <!--
    var param = 1
    function myPlay(par) {

    if (par!=param) {return}

    var currentdate = 0
    var theranmidi = " "
    var core = 0

    function StringArray (n) {
    this.length = n;
    for (var i =1; i <= n; i++) {
    this[i] = ' '

    }
    }

    midi = new StringArray(1)
    mid0 = "http://www.greektownimports.com/music/solobouzouki.ram"
    //mid1 = "http://www.greektownimports.com/music/solobouzouki.ram"
    //mid2 = "http://www.greektownimports.com/music/solobouzouki.ram"
    midr = 0
    now=new Date()
    midr=(now.getSeconds() )%1
    mide = " "
    if (midr == 0)
    {{mide = mid0}
    name =("lalala")}
    if (midr == 1)
    {{mide = mid1}
    name =("test")}
    if (midr == 2)
    {{mide = mid2}
    name =("testtesttset")}


    {document.write('<div style="position:absolute;left:200;top:200"><embed name="midi"

    src="'+mide+'" loop="1" autostart="true" hidden="false" width="300" height="100"></div>');
    }

    }

    </script>


    </head>
    <body>

    </body>
    </html>

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    <script type="text/javascript">
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    New Coder
    Join Date
    Jun 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hurra!!!

    It works now. Stupid of me to forget " in the <script type="text/javascript">
    Thanks very much glenngv and kor


    mx-guest2004

  • #11
    New Coder
    Join Date
    Jun 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's me again.
    The object appears in the right position but only on a new page. I have to click back button to get back to my main page.
    I have other text and images in my main page and want to have this object on the same page.

    mx-guest2004

  • #12
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Since you have document.write in the script, put it inside the <body> tag instead of the <head>.
    Last edited by glenngv; 06-14-2004 at 02:57 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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