1
gary711
how to make some javascript work in a custom block??
  • 2005/3/4 4:21

  • gary711

  • Just popping in

  • Posts: 13

  • Since: 2004/8/3 6


how to make the following javascript work in a custom block??

<script language="Javascript" type="text/javascript">
<!--
var 
tl=new Array(

"Welcome to my site.",
"you can find some XOOPS hack here,",
"and you can also see some sports video here.",
"...............",
"#$%&@#",
);
var 
speed=60;
var 
index=0text_pos=0;
var 
str_length=tl[0].length;
var 
contentsrow;

function 
type_text()
{
    
contents='';
    
row Math.max(0,index-7);
    while(
row<index)
        
contents += tl[row++] + 'rn';
    
document.forms[0].elements[0].value contents tl[index].substring(0,text_pos) + "_";
    if(
text_pos++==str_length)
    {
        
text_pos=0;
        
index++;
        if(
index!=tl.length)
        {
            
str_length=tl[index].length;
            
setTimeout("type_text()",1500);
        }
    }
    else
        
setTimeout("type_text()",speed);
}
//-->
</script>

<
body bgcolor='#ffffff' text='#000000' alink='#ff0000' vlink='#00007f' link='#0000ff' onLoad="type_text();">

<
table border="0" cellpadding="0" cellspacing="0" align="center" height="100%" width="100%">
<
tr><td align="center" valign="middle">
    <
h2>err ...... </h2>
    
    <
form><textarea rows="3" cols="60" wrap="soft"></textarea></form>

2
Mithrandir
Re: how to make some javascript work in a custom block??

Copy-paste into an HTML-type block?

3
rowdie
Re: how to make some javascript work in a custom block??
  • 2005/3/4 9:24

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


First problem is the html 'body' tag, you've already got one in your theme, putting it in a block as well means there will be two body tags on your page.

Next, all your html tags are not closed... maybe you haven't posted the whole code?

I'm no javascript expert, but it looks like this code relies on there being only one form on your page... or that this form is the first one. Is that the case on the page you are trying to place this block?

I suggest you try including the javascript in your theme. Then you can use the theme's html body "onLoad" element.

4
carnuke
Re: how to make some javascript work in a custom block??
  • 2005/3/4 10:13

  • carnuke

  • Home away from home

  • Posts: 1955

  • Since: 2003/11/5


This script has some syntax errors. It won't even work on an ordinary html page. I suspect there is a further part that is missing?

5
gary711
Re: how to make some javascript work in a custom block??
  • 2005/3/4 10:56

  • gary711

  • Just popping in

  • Posts: 13

  • Since: 2004/8/3 6


the whole code
<html>
<
head>
<
script language="Javascript" type="text/javascript">
<!--
var 
tl=new Array(

"Welcome to my site.",
"you can find some XOOPS hack here,",
"and you can also see some sports video here.",
"...............",
"#$%&@#",
);
var 
speed=60;
var 
index=0text_pos=0;
var 
str_length=tl[0].length;
var 
contentsrow;

function 
type_text()
{
    
contents='';
    
row Math.max(0,index-7);
    while(
row<index)
        
contents += tl[row++] + 'rn';
    
document.forms[0].elements[0].value contents tl[index].substring(0,text_pos) + "_";
    if(
text_pos++==str_length)
    {
        
text_pos=0;
        
index++;
        if(
index!=tl.length)
        {
            
str_length=tl[index].length;
            
setTimeout("type_text()",1500);
        }
    }
    else
        
setTimeout("type_text()",speed);
}
//-->
</script>
</
head>

<
body bgcolor='#ffffff' text='#000000' alink='#ff0000' vlink='#00007f' link='#0000ff' onLoad="type_text();">

<
table border="0" cellpadding="0" cellspacing="0" align="center" height="100%" width="100%">
<
tr><td align="center" valign="middle">
    <
h2>err ...... </h2>
    
    <
form><textarea rows="10" cols="60" wrap="soft"></textarea></form>

    <
br /><br />
      <
a href="http://gary711.idv.st"> - gary711 - </a></td></tr>
</
table>

</
body>
</
html>


can you tell me how to including the javascript in my theme and use the theme's html body "onLoad" element

thanx for helping me

Login

Who's Online

170 user(s) are online (110 user(s) are browsing Support Forums)


Members: 0


Guests: 170


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits