Title: document.write() and alert() Post by: Agent Moose on May 29, 2009, 08:28:09 am document.write()
The document.write() function allowes you to write anything onto a page. So, if I want to say Hello World, I would use this: Code: <script type="type/javascript"> document.write("Hello World"); </script> You can also use HTML with it too. Another thing you can do is call other functions or variables through a document.write() function. here is an example of a variable being used: Code: <script type="type/javascript"> var text = "Hello World"; document.write(text); </script> You may also use HTML there. alert() The alert() function alowes you to create a pop-up. So, if you wanted to create a pop-up with the text Hello World, you would do this: Code: <script type="type/javascript"> alert("Hello World"); </script> You may use HTML with it. Just like the document.write() function, you can use a variable. Code: <script type="type/javascript"> var text = "Hello World" alert(text); </script> That would make do the same thing as the alert("Hello World"). Title: Re: document.write() and alert() Post by: Andrew on May 29, 2009, 09:13:03 am This ones, pretty simple, but really good :)
So, if I used this, would it only show up once on the forum? Or would it come up everytime someone refreshed? Code: <script type="type/javascript"> alert("Welcome to Partners in Crime!"); </script> Title: Re: document.write() and alert() Post by: Agent Moose on May 29, 2009, 09:23:08 am Every time someone refreshes.
Title: Re: document.write() and alert() Post by: Mojobojo82 on June 17, 2009, 05:26:45 am That would be annoying :P I thought there was one When you first go on the Website and when you leave it :P
Title: Re: document.write() and alert() Post by: Exilis on June 17, 2009, 05:43:33 am For that you would need to use cookies. Cookies in any language can be confusing, but maybe Moose will make a tutorial about them sometime. |