By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

Javascript within another Javascript Instance

P: 4
I am totally new to Javascript, and would desperately like some help. I have downloaded a Javascript Text Scroller that uses DHTML to scroll text up and down. There are other Java scrollers that do the same thing. My problem is that the Java always has code to place "fixed" or "static" text for scrolling. So I have to manually enter the words I need scrolled.

Now . . I am also using a service called "FlexWindow" (www.flexwindow.com) where you can create dynamic areas of a website, and update them via email. Each time you update the dynamic window via email, is writes a .JS file in a specific directory:

http://www.scottishvoice.net/flexwindow/about.js

The main webpage simply calls for this Javascript with the following source:

<script src='http://www.scottishvoice.net/flexwindow/tickertape.js'></script>

The problem is that I would like to embed this Java in a Smooth Scroller or Marquee Javascript, but I cannot get it working. Most of them have lines such as:

myScroller1.addItem("Hello from Scottish Voice");

I need to replace the text inside the quotes with the .js Java from above. I cannot get it to work at all.

Is it a limitation to do multiple calls for Javascript within the same page?

I would appreciate any assistance the experts can give me.

Thanks in advance.
Kevin Sneddon
Cartman Creative
Oct 20 '07 #1
Share this Question
Share on Google+
5 Replies


gits
Expert Mod 5K+
P: 5,352
hi ...

please post the attempt you have made ... so that we may have a closer look at it ...

kind regards
Oct 20 '07 #2

P: 4
Thanks for the response. OK, here goes:

The script I have downloaded to give me a text scroller is this one:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.2">
  2.  
  3. //Specify the marquee's width (in pixels)
  4. var marqueewidth="300px"
  5. //Specify the marquee's height
  6. var marqueeheight="25px"
  7. //Specify the marquee's marquee speed (larger is faster 1-10)
  8. var marqueespeed=2
  9. //configure background color:
  10. var marqueebgcolor="#DEFDD9"
  11. //Pause marquee onMousever (0=no. 1=yes)?
  12. var pauseit=1
  13.  
  14. var marqueecontent='<nobr>This is the Text I need replaced by another Javascript instance</nobr>'
  15.  
  16. marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
  17. var copyspeed=marqueespeed
  18. var pausespeed=(pauseit==0)? copyspeed: 0
  19. var iedom=document.all||document.getElementById
  20. if (iedom)
  21. document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent+'</span>')
  22. var actualwidth=''
  23. var cross_marquee, ns_marquee
  24.  
  25. function populate(){
  26. if (iedom){
  27. cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
  28. cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
  29. cross_marquee.innerHTML=marqueecontent
  30. actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
  31. }
  32. else if (document.layers){
  33. ns_marquee=document.ns_marquee.document.ns_marquee2
  34. ns_marquee.left=parseInt(marqueewidth)+8
  35. ns_marquee.document.write(marqueecontent)
  36. ns_marquee.document.close()
  37. actualwidth=ns_marquee.document.width
  38. }
  39. lefttime=setInterval("scrollmarquee()",20)
  40. }
  41. window.onload=populate
  42.  
  43. function scrollmarquee(){
  44. if (iedom){
  45. if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
  46. cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
  47. else
  48. cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
  49.  
  50. }
  51. else if (document.layers){
  52. if (ns_marquee.left>(actualwidth*(-1)+8))
  53. ns_marquee.left-=copyspeed
  54. else
  55. ns_marquee.left=parseInt(marqueewidth)+8
  56. }
  57. }
  58.  
  59. if (iedom||document.layers){
  60. with (document){
  61. document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
  62. if (iedom){
  63. write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
  64. write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
  65. write('<div id="iemarquee" style="position:absolute;left:0px;top:0px"></div>')
  66. write('</div></div>')
  67. }
  68. else if (document.layers){
  69. write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
  70. write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
  71. write('</ilayer>')
  72. }
  73. document.write('</td></table>')
  74. }
  75. }
  76. </script>
Now I want to change the line: var marqueecontent='<nobr>This is the Text I need replaced by another Javascript instance</nobr>'

. . so that it contains this:

<script src='http://www.scottishvoice.net/flexwindow/tickertape.js'></script>

I have absolutely no idea how to slot it in, and each time I do it fails.

Any help or advice would be very much appreciated.

Regards,
Kevin
Oct 24 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Your tickertape.js file just contains document.writeln statements. These will write to the page within a div element, rather than set (a) variable(s) for a marquee. Do you just want to display them on the page?
Oct 25 '07 #4

P: 4
Yes. The "tickertape.js" is a script service I have subscribed to, that allows a page to be updated by email. A customer sends an email to the "service" which in turn, creates an updated tickertape.js that contains the WRITELN statements to build up the page content. I simply place the ".js" where I need the dynamic page to appear . . and everything falls into place.

What I need however is the marquee content to be able to be changed, by updating the contents of the "tickertape.js" file.

Thanks . . . .

Kevin
Oct 25 '07 #5

acoder
Expert Mod 15k+
P: 16,027
You could set the marquee content variable using tickertape.js. To include this within the JavaScript, either close the script tag, include the script after it and open a new script tag for the rest of the code:
[HTML]</script>
<script type="text/javascript" src="tickertape.js"></script>
<script type="text/javascript>
// rest of the code...[/HTML] OR include the file within the JavaScript like this:
Expand|Select|Wrap|Line Numbers
  1. document.write("<script type=\"text/javascript\" src=\"tickertape.js\"><\/script>");
Oct 26 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.