HTML link updates value for javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • risk32
    New Member
    • Mar 2008
    • 98

    HTML link updates value for javascript

    Hi all,
    I have a quick question. I'm using Uncle Jim's vertical scrolling text script from
    http://jdstiles.com and I'm trying to modify it to suit my needs. I'm not sure if this can be done, but I'm trying to find some research on how to do it properly if it can. I have an href link on the page with the default location left blank, and a value that I need the JS to read and use it for the output. However, the scrolling text box won't show up when the page loads and the link opens up the directory that the file is in with Windows Explorer.

    Here's what I have:
    Code:
     
    <html>
    
    <script type="text/javascript"><!-- 
    /*
     _____________________________________
    /¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\
    | Another JavaScript from Uncle Jim   |
    | Feel free to copy, use and change   |
    | this script as long as this part    |
    | remains unchanged. You can visit    |
    | my website at http://jdstiles.com   |
    | for more scripts like this one.     |
    | Created: 1996 Updated: 2006         |
    \_____________________________________/
     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    */
    
    //Specify the marquee's width (in pixels)
    var marqueewidth=450
    //Specify the marquee's height
    var marqueeheight=50
    //Specify the marquee's scroll speed (larger is faster)
    var speed=2
    //Specify the marquee contents
    var marqueecontents= document.getElementById('song').value
    if (document.all)
    document.write('<marquee direction="up" scrollAmount='+speed+' style="width:'+marqueewidth+';background-color:black;border:1px solid black;height:'+marqueeheight+'">'+marqueecontents+'</marquee>')
    function regenerate(){
    window.location.reload()
    }
    function regenerate2(){
    if (document.layers){
    setTimeout("window.onresize=regenerate",450)
    intializemarquee()
    }
    }
    
    function intializemarquee(){
    document.cmarquee01.document.cmarquee02.document.write(marqueecontents)
    document.cmarquee01.document.cmarquee02.document.close()
    thelength=document.cmarquee01.document.cmarquee02.document.height
    scrollit()
    }
    
    function scrollit(){
    if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){
    document.cmarquee01.document.cmarquee02.top-=speed
    setTimeout("scrollit()",100)
    }
    else{
    document.cmarquee01.document.cmarquee02.top=marqueeheight
    scrollit()
    }
    }
    
    window.onload=regenerate2
    </script>
    <div style=border:1px solid blue;">
    <ilayer width=&{marqueewidth}; height=&{marqueeheight}; name="cmarquee01" >
    <layer name="cmarquee02" width=&{marqueewidth}; height=&{marqueeheight}; ></layer></ilayer>
    </div>
    
    <a href="" value="You know you\'re all alone<br>Your friends they aren\'t at home<br>Everybody\'s gone to the garden<br>As you look into the trees<br>You can look but you don\'t see<br>The flowers seem to tease you at the garden<br>Everybody\'s there\, but you don\'t seem to care<br>What\'s it with you man\, and this garden<br><br>Turned into my worst phobia\,<br>A crazy man\'s utopia<br>If you\'re lost no one can show ya\,<br>But it sure was glad to know ya<br>Only poor boys take a chance\,<br>On the garden\'s song and dance\,<br>Feel her flowers as they wrap around\,<br>But only smart boys do without<br>You can find it all inside<br>No need to wrestle with your pride<br>No you ain\'t losin\' your mind<br>You\'re just in the garden<br>They can lead you to yourself<br>Or you can throw it on the shelf<br>But you know you can look inside<br>For the garden<br><br>I wasn\'t really scared<br>Lost my virginity there\,<br>To a gypsy with blond hair<br>But now no one seems to care<br>Like a mouse inside a maze<br>Wandering round 4 daze<br>With a smile upon my face\,<br>I never wanna leave this place<br>Only poor boys take a chance\,<br>On the garden\'s song and dance\,<br>Feel her flowers as they wrap around\,<br>But only smart boys do without<br>Turned into my worst phobia\,<br>A crazy man\'s utopia<br>If you\'re lost no one can show ya\,<br>But it sure was glad to know ya<br>Bye bye<br>So long\, bye bye<br>It\'s glad to know ya<br>Bye bye<br>Bye bye<br>Aw\.\.\.so long<br>" id="song">Guns n' Roses - In The Garden</a>
    </html>
    P.S
    The value is written on one line since JS doesn't like one string to be broken up on multiple lines
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    that seems like an absolutly outdated script ... have a look at those ilayer and marquee tags that are used there ... did you ever saw that in action in a modern browser? basicly it would be much better to write a new and reliable script ... but that's my personal opinion regarding such a small task ...

    kind regards

    Comment

    • risk32
      New Member
      • Mar 2008
      • 98

      #3
      Gits,
      I am aware that modern browsers would not use this style of coding, however, this is just something that I stumbled upon. I have no idea how to do this myself, that's why I'm asking how to do it. Of course, not get an entire script built for me, but just something to point me in the right direction.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        so ... first describe the requirements and then show what you would do to start ... the script itself couldn't be too complicated ... so if you wouldn't mind to invest some efforts then we could develop it here together ...

        Comment

        • risk32
          New Member
          • Mar 2008
          • 98

          #5
          I did find this, which seems a little more modern compared to marquees and ilayers...

          Instead of using the two mentioned above, it uses an iframe to contain the scrolling text. In the external html file, there is a section for text that can be edited to display the content. Might be a bogus idea, but I thought about starting with a <p> tag that has an id, and using JS to modify the innerHTML for that tag depending on what the value is set to (whether it be dropdown, radio, hyperlink, etc). What I can seem to find though, is how to slow the scroll speed. I set it to 1, but it's still so darn fast. This isn't complete, but here's what I have so far:

          External.html
          Code:
          <html>
          <body>
          
          <div id="datacontainer" style="position:absolute;left:1px;top:10px;width:100%" onMouseover="scrollspeed=0" onMouseout="scrollspeed=cache">
          
          <!-- ADD YOUR SCROLLER CONTENT INSIDE HERE -->
          
          <p id="text">
          You know you're all alone<br>
          Your friends they aren't at home<br>
          Everybody's gone to the garden<br>
          As you look into the trees<br>
          You can look but you don't see<br>
          The flowers seem to tease you at the garden<br>
          Everybody's there, but you don't seem to care<br>
          What's it with you man, and this garden<br>
          <br>Turned into my worst phobia,<br>
          A crazy man's utopia<br>
          If you're lost no one can show ya,<br>
          But it sure was glad to know ya<br>
          Only poor boys take a chance,<br>
          On the garden's song and dance,<br>
          Feel her flowers as they wrap around,<br>
          But only smart boys do without<br>
          You can find it all inside<br>
          No need to wrestle with your pride<br>
          No you ain't losin' your mind<br>
          You're just in the garden<br>
          They can lead you to yourself<br>
          Or you can throw it on the shelf<br>
          But you know you can look inside<br>
          For the garden<br><br>
          I wasn't really scared<br>
          Lost my virginity there,<br>
          To a gypsy with blond hair<br>
          But now no one seems to care<br>
          Like a mouse inside a maze<br>
          Wandering round 4 daze<br>
          With a smile upon my face,<br>
          I never wanna leave this place<br>
          Only poor boys take a chance,<br>
          On the garden's song and dance,<br>
          Feel her flowers as they wrap around,<br>
          But only smart boys do without<br>
          Turned into my worst phobia,<br>
          A crazy man's utopia<br>
          If you're lost no one can show ya,<br>
          But it sure was glad to know ya<br>
          Bye bye<br>
          So long, bye bye<br>
          It's glad to know ya<br
          >Bye bye<br>
          Bye bye<br>
          Aw...so long<br>
          </p>
          
          <!-- END SCROLLER CONTENT -->
          
          </div>
          
          <script type="text/javascript">
          
          /***********************************************
          * IFRAME Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
          * This notice MUST stay intact for legal use
          * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
          ***********************************************/
          
          //Specify speed of scroll. Larger=faster (ie: 5)
          var scrollspeed=cache=1
          
          //Specify intial delay before scroller starts scrolling (in miliseconds):
          var initialdelay=500
          
          function initializeScroller(){
          dataobj=document.all? document.all.datacontainer : document.getElementById("datacontainer")
          dataobj.style.top="5px"
          setTimeout("getdataheight()", initialdelay)
          }
          
          function getdataheight(){
          thelength=dataobj.offsetHeight
          if (thelength==0)
          setTimeout("getdataheight()",10)
          else
          scrollDiv()
          }
          
          function scrollDiv(){
          dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
          if (parseInt(dataobj.style.top)<thelength*(-1))
          dataobj.style.top="5px"
          setTimeout("scrollDiv()",60)
          }
          
          if (window.addEventListener)
          window.addEventListener("load", initializeScroller, false)
          else if (window.attachEvent)
          window.attachEvent("onload", initializeScroller)
          else
          window.onload=initializeScroller
          
          </script>
          
          </body>
          </html>
          Test.html
          Code:
          <HTML>
          <script type="text/javascript">
          
          /***********************************************
          * IFRAME Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
          * This notice MUST stay intact for legal use
          * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
          ***********************************************/
          
          //specify path to your external page:
          var iframesrc="external.htm"
          
          //You may change most attributes of iframe tag below, such as width and height:
          document.write('<iframe id="datamain" src="'+iframesrc+'" width="300px" height="150px" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"></iframe>')
          
          </script>
          </HTML>

          Comment

          Working...