Jump to content

setTimeout syntax problem


gareth2

Recommended Posts

could some one tell me what is wrong with this.
[code]<p align=center id=message_0 

style=visibility:hidden>You attack $stat1[user] for

$stat[att].</p>
<script>
var message_0 = 

document.getElementById(message_0);
window.setTimeout(message_0.style.visibility='visib

le', 100);</script>[/code]
Link to comment
Share on other sites

I am by no means and expert, so take this with a grain of salt, but on the HTML side of things "align" is a deprecated attribute with regard to the <p> tags. You also should have id="message_0" and style="visibility:hidden" (if your intention is for the latter to be a CSS style).
Link to comment
Share on other sites

darrin365 is on the right track. Your main issue is that within your getElementById() function call, you must have the id name within quotes. In addition, you really need to clean up your markup, or you'll have all sorts of issues in the long run. Also, your setTimeout function accepts a [b]string[/b] as the first parameter, not straight code. So, you need to either write a function that will show what you're after, and call that function, or you need to encapsulate your script to run within quotes:
[code]
<p align="center" id="message_0 " style="visibility:hidden;">
You attack $stat1[user] for $stat[att].
</p>

<script type="text/javascript">
function showDiv(id) {
  var myDiv = document.getElementById(id);
  myDiv.style.visibility = 'visible';
}

window.setTimeout('showDiv("message_0")', 100);
</script>
[/code]

Good luck.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.