Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call a function using javascript

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hi,

I have created a function that will place scrolling text in the status bar of my browser.

The code below works when I place it inside a web page and call that function from the onload="scrolltext"! However I will have to place this code inside every webpage, not very efficient.

So I placed this same function into a separate java script file scrolltext.js

Inside my webpage i call the function:

<script language=&quot;Jscript&quot;><!--
src =&quot;..\scripts\rolltext.js&quot;
</script>

This does not work, can someone please help me...

Thankyou
newbie_99999
 
Hi,

I tried what you suggested but my it did not work.

I received an error message 512 : object expected, this line contains my onload=&quot;scrolltext()&quot; code.

I removed this code and reloaded the file and nothing happened in my status bar.

please help....

thankyou
 
hi,

The scroll text code is below:

<script language=&quot;JavaScript1.2&quot;>

var msg = &quot;......Place your message here...&quot;;

function scrolltext()
{
window.status = msg;
msg = msg.substring(1, msg.length) + msg.substring(0, 1);
setTimeout(&quot;scrolltext()&quot;, 200);
}

</script>


If I place this code inside a html page and call it, it works:

<body onload=&quot;scrolltext()&quot;>

</body>

Thankyou,

newbie_99999
 
This explains why. Your rolltext.js file is NOT just a JavaScript file. It contains all other HTML tag.

You should just have this in your scrolltext.js file.

var msg = &quot;......Place your message here...&quot;;

function scrolltext()
{
window.status = msg;
msg = msg.substring(1, msg.length) + msg.substring(0, 1);
setTimeout(&quot;scrolltext()&quot;, 200);
}

Put the rest on any page that you'd like to have this scrolltext effect.
<body onload=&quot;scrolltext()&quot;>

</body>

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top