Advertise Here

Author Topic: Random Message  (Read 3926 times)

0 Members and 1 Guest are viewing this topic.

Offline [JeReMy]

  • SMF For Free Master
  • *
  • Posts: 1174
  • www.ourhangout.org
    • View Profile
    • ourhangout

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Random Message
« on: January 18, 2009, 12:18:03 am »
Forum Url: http://planetgfx.smfforfree.com
Code: [Select]
<html>
<head>

<script type="text/javascript">
function myfunction()
{
alert("HELLO");
alert("WELCOME TO THE FORUM");
alert("ENJOY YOUR STAY");
}
</script>

</head>
<body>

<form>
<input type="button"
onclick="myfunction()"
value="Hello!">
</form>

<p>Hello! </p>

</body>
</html>

Add this to your headers/footers when you click it it will say hello etc what ever you want i've made it to say HELLO
WELCOME TO THE FORUM
ENJOY YOUR STAY
if you want to change these just edit this

Code: [Select]
alert("HELLO");
alert("WELCOME TO THE FORUM");
alert("ENJOY YOUR STAY");

it could also be used as a joke also this is my first try
« Last Edit: January 18, 2009, 12:25:22 am by δharp Shot »

Offline Jessie

  • SMF For Free Hero
  • *
  • Posts: 754
    • View Profile
    • iSimple

  • Total Badges: 18
    Badges: (View All)
    Windows User Apple User Mobile User Topic Starter Combination
Re: Random Message
« Reply #1 on: January 18, 2009, 12:28:27 am »
Nice code Sharp Shot.
Feel free to PM me or email me. ;)

My Forum :)

Offline [JeReMy]

  • SMF For Free Master
  • *
  • Posts: 1174
  • www.ourhangout.org
    • View Profile
    • ourhangout

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #2 on: January 18, 2009, 12:30:58 am »
Thanks

Offline - Lawrence -

  • SMF For Free Hero
  • *
  • Posts: 549
    • View Profile

  • Total Badges: 15
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #3 on: January 18, 2009, 04:56:01 am »
Wow, nice code, where will the message actually appear though?

Offline Celebrus

  • SMF For Free Hero
  • *
  • Posts: 941
    • View Profile
    • Vikhyat Korrapati

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #4 on: January 18, 2009, 05:55:58 am »
Did you really make that?

If you didn't- know that codes from sites like dynamic drive aren't supposed to be used as they originally were, you've got to remove all that HTML and stuff around it.

If you did- you don't need to wrap the code in <html>, <head> and <body> tags. This code would have worked even if it was like this-
Code: [Select]
<script type="text/javascript">
function myfunction()
{
alert("HELLO");
alert("WELCOME TO THE FORUM");
alert("ENJOY YOUR STAY");
}
</script>
<input type="button" onclick="myfunction()" value="Hello!" />

Offline [JeReMy]

  • SMF For Free Master
  • *
  • Posts: 1174
  • www.ourhangout.org
    • View Profile
    • ourhangout

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #5 on: January 18, 2009, 09:37:43 am »
i learnt it from w3schools

Offline Didds

  • SMF For Free Sr. Member
  • *
  • Posts: 269
  • Didds Forums
    • View Profile
    • Didds Forums

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #6 on: January 18, 2009, 12:50:44 pm »
Very nice code, is there a way to prevent it from allowing a check box to disable more messages. (Or is that a browser thing). Also, is there a way to make it open automatically without clicking?

Thanks

Offline [JeReMy]

  • SMF For Free Master
  • *
  • Posts: 1174
  • www.ourhangout.org
    • View Profile
    • ourhangout

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #7 on: January 18, 2009, 12:56:59 pm »
Code: [Select]
<html>
<head>
<script type="text/javascript">
function detectBrowser()
{
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
if ((browser=="Netscape"||browser=="Microsoft Internet Explorer") && (version>=4))
  {
  alert("HELLO!");
  }
else
  {
  alert("BYE!");
  }
}
</script>
</head>

<body onload="detectBrowser()">
</body>

</html>


add to headers/footers it will popup when you enter the page to change it edit

Code: [Select]
alert("HELLO!");
note this happens when ever you open any board and wen u enter the forum
« Last Edit: January 18, 2009, 12:59:13 pm by Sharp Shot »

Offline - Lawrence -

  • SMF For Free Hero
  • *
  • Posts: 549
    • View Profile

  • Total Badges: 15
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #8 on: January 18, 2009, 01:09:57 pm »
...

note this happens when ever you open any board and wen u enter the forum

It happens whenever you view any page on the site, and can be very annoying ;).

Offline [JeReMy]

  • SMF For Free Master
  • *
  • Posts: 1174
  • www.ourhangout.org
    • View Profile
    • ourhangout

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #9 on: January 18, 2009, 01:31:23 pm »
thats why i noted it  ;)

Offline Didds

  • SMF For Free Sr. Member
  • *
  • Posts: 269
  • Didds Forums
    • View Profile
    • Didds Forums

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #10 on: January 18, 2009, 01:43:28 pm »
Hmmm, is there any way to make it only appear on certain page?  :angel:

Offline [JeReMy]

  • SMF For Free Master
  • *
  • Posts: 1174
  • www.ourhangout.org
    • View Profile
    • ourhangout

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #11 on: January 18, 2009, 01:47:09 pm »
yes there probably is ill work on thaat im still learning javascript so.....

Offline valhalla95

  • SMF For Free Member
  • *
  • Posts: 30
    • View Profile
    • {LYLE CODING}

  • Total Badges: 9
    Badges: (View All)
    Topic Starter Combination Level 2 Level 1 10 Posts
Re: Random Message
« Reply #12 on: January 19, 2009, 11:28:04 am »
Forum Url: http://moodle.smfforfree.com
good code sharp



Offline Didds

  • SMF For Free Sr. Member
  • *
  • Posts: 269
  • Didds Forums
    • View Profile
    • Didds Forums

  • Total Badges: 14
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #13 on: January 19, 2009, 03:40:59 pm »
yes there probably is ill work on thaat im still learning javascript so.....

Ok :) Thanks

Offline - Lawrence -

  • SMF For Free Hero
  • *
  • Posts: 549
    • View Profile

  • Total Badges: 15
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
Re: Random Message
« Reply #14 on: January 23, 2009, 03:14:53 pm »
I have been working on an alert that appears only once every session, as was mentioned earlier. Maybe someone could merge the 2 codes. Here it is:

Add this to the Headers or footers:
Code: [Select]
<script>

//Code created by Lawrence.

var alertmessage="EDIT THIS TEXT!"

var once_per_session=1


function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      end = document.cookie.indexOf(";", offset);
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function alertornot(){
if (get_cookie('alerted')==''){
loadalert()
document.cookie="alerted=yes"
}
}

function loadalert(){
alert(alertmessage)
}

if (once_per_session==0)
loadalert()
else
alertornot()

</script>
You need to edit this bit:
Code: [Select]
var alertmessage="EDIT THIS TEXT!"The part that says "EDIT THIS TEXT".

Also make not this doesn't bring up a random message just an alert box per session.
Also note it may not work if you have disabled cookies, and javascript ;).
« Last Edit: January 23, 2009, 03:17:23 pm by - Lawrence - »

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
4819 Views
Last post November 23, 2007, 06:28:49 pm
by trevix
0 Replies
1456 Views
Last post January 26, 2008, 03:36:52 pm
by !The Sims!
0 Replies
779 Views
Last post February 09, 2008, 04:58:19 am
by Clarisse123
7 Replies
1885 Views
Last post February 26, 2008, 03:37:58 pm
by Max.
1 Replies
1916 Views
Last post January 09, 2009, 05:23:23 pm
by Colette Brunel