Forum Topic: Randomised Html <title> Tags

(224 views • 13 replies)

This topic is 1 page long.

<< < > >>
None

SplitFusion

Reply To Post Reply & Quote

Posted at: 7/16/06 05:14 AM

SplitFusion LIGHT LEVEL 10

Sign-Up: 08/19/05

Posts: 52

How do I code in randomised <title> tags into my website. Basically, I would like it that each time you reload the page, you get a new title appear.

Similar to the bungie.net concept.


None

elbekko

Reply To Post Reply & Quote

Posted at: 7/16/06 07:36 AM

elbekko EVIL LEVEL 16

Sign-Up: 07/23/04

Posts: 6,450

Does your site support PHP?

"My software never has bugs. It just develops random features. " - Unknown

[ PHP: Main | Omigod, a blog ]

BBS Signature

None

DannyIsOnFire

Reply To Post Reply & Quote

Posted at: 7/16/06 08:19 AM

DannyIsOnFire DARK LEVEL 16

Sign-Up: 04/14/05

Posts: 6,393

At 7/16/06 07:36 AM, elbekko wrote: Does your site support PHP?

No, its hosted by Freewebs.

BBS Signature

None

elbekko

Reply To Post Reply & Quote

Posted at: 7/16/06 08:41 AM

elbekko EVIL LEVEL 16

Sign-Up: 07/23/04

Posts: 6,450

Pff... I guess it can be done by JS too, but I have no idea on how to randomise and work with arrays in JS :P

"My software never has bugs. It just develops random features. " - Unknown

[ PHP: Main | Omigod, a blog ]

BBS Signature

None

DannyIsOnFire

Reply To Post Reply & Quote

Posted at: 7/16/06 09:00 AM

DannyIsOnFire DARK LEVEL 16

Sign-Up: 04/14/05

Posts: 6,393

At 7/16/06 08:41 AM, elbekko wrote: Pff... I guess it can be done by JS too, but I have no idea on how to randomise and work with arrays in JS :P

<script type="text/javascript">

var Statements = new Array(

'bla1',
'bla2',
);

function GetStatement(outputtype)
{
if(++Number > Statements.length - 1) Number = 0;
if (outputtype==0)
document.write(Statements[Number])
else if (document.getElementById)
document.getElementById("ponder").innerHTM
L=Statements[Number];
}
function GetRandomNumber(lbound, ubound)
{
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}
var Number = GetRandomNumber(0, Statements.length - 1);

</script>

It may look screwy on the BBS, but you get the jist of it hopefully.

BBS Signature

None

seel

Reply To Post Reply & Quote

Posted at: 7/16/06 09:01 AM

seel FAB LEVEL 19

Sign-Up: 06/27/05

Posts: 2,196

At 7/16/06 08:41 AM, elbekko wrote: Pff... I guess it can be done by JS too, but I have no idea on how to randomise and work with arrays in JS :P

I know, its almost like actionscript, settup the array and use random(number) to randomize.. I suggest you learn javascript OR get a REAL host that supports php.


None

DannyIsOnFire

Reply To Post Reply & Quote

Posted at: 7/16/06 09:07 AM

DannyIsOnFire DARK LEVEL 16

Sign-Up: 04/14/05

Posts: 6,393

At 7/16/06 09:01 AM, seel wrote: get a REAL host that supports php.

FREEWEBS IS TEH 1337 HOST U N00B !!!

P
BBS Signature

None

elbekko

Reply To Post Reply & Quote

Posted at: 7/16/06 09:29 AM

elbekko EVIL LEVEL 16

Sign-Up: 07/23/04

Posts: 6,450

At 7/16/06 09:00 AM, DannyIsOnFire wrote:
At 7/16/06 08:41 AM, elbekko wrote: Pff... I guess it can be done by JS too, but I have no idea on how to randomise and work with arrays in JS :P
<script type="text/javascript">

var Statements = new Array(

'bla1',
'bla2',
);

...

Looks like an awful long way to do
echo $statements[array_rand($statements)];

:P

"My software never has bugs. It just develops random features. " - Unknown

[ PHP: Main | Omigod, a blog ]

BBS Signature

None

Momo-the-Monkey

Reply To Post Reply & Quote

Posted at: 7/16/06 09:48 AM

Momo-the-Monkey EVIL LEVEL 30

Sign-Up: 10/15/05

Posts: 3,096

At 7/16/06 09:29 AM, elbekko wrote:
At 7/16/06 09:00 AM, DannyIsOnFire wrote:
At 7/16/06 08:41 AM, elbekko wrote: Pff... I guess it can be done by JS too, but I have no idea on how to randomise and work with arrays in JS :P
<script type="text/javascript">

var Statements = new Array(

'bla1',
'bla2',
);

...
Looks like an awful long way to do
echo $statements[array_rand($statements)];

P

yea but he can't use php. He's using freewebs. Just get a real host you freak. And stop using freewebs............forever.

You should see Gir's Soundboard...
{ PHP: Main | | Java: Main }
Every Villian Is Lemons

BBS Signature

None

seel

Reply To Post Reply & Quote

Posted at: 7/16/06 10:26 AM

seel FAB LEVEL 19

Sign-Up: 06/27/05

Posts: 2,196

At 7/16/06 09:07 AM, DannyIsOnFire wrote:
At 7/16/06 09:01 AM, seel wrote: get a REAL host that supports php.
FREEWEBS IS TEH 1337 HOST U N00B !!!
P

GAAAAAAAAAWD I HAVE BEEN MADE FOOL OF FOR BUYING A 100$ A MONTH HOST WITH SUPORT FOR EVERYTHING AND 100GB SPACE OMFG DAMN I HAVE TO GET FREEWEBS!!!! =<

lawl

None

Pilot-Doofy

Reply To Post Reply & Quote

Posted at: 7/16/06 11:08 PM

Pilot-Doofy LIGHT LEVEL 37

Sign-Up: 09/13/03

Posts: 12,282

At 7/16/06 09:29 AM, elbekko wrote: Looks like an awful long way to do
echo $statements[array_rand($statements)];

It could be abbreviated quite substanstially if he had not copied and pasted that code directly from a website and actually knew what he was doing. Anywho, it will work so there's no point in me writing out another set of code.

Also, since it's on the client-side, it will be (usually) much faster than a server-side code. So in this case, even if he had PHP, it wouldn't be worth using.

JS is faster and requires less work to acquire a working module in this situation. Although PHP would offer 100% browser compatibility, JS is still a good choice here.

There is one thing I would add to the script though. If the user doesn't have Javascript enabled then they won't see a title. Try this:

<noscript>
document.write('<title>Default Title Here</title>');
</noscript>

Now, if the browser doesn't support Javascript at all, then (in most cases) even the default title will not appear, and you're just SOL.

holy jesus what are these goddamn animals


None

WoogieNoogie

Reply To Post Reply & Quote

Posted at: 7/16/06 11:40 PM

WoogieNoogie LIGHT LEVEL 14

Sign-Up: 06/26/05

Posts: 3,195

At 7/16/06 11:08 PM, Pilot-Doofy wrote: <noscript>
document.write('<title>Default Title Here</title>');
</noscript>

Now wait right there...wouldn't that be normal HTML inside the noscript tags?


None

DFox

Reply To Post Reply & Quote

Posted at: 7/16/06 11:44 PM

DFox LIGHT LEVEL 30

Sign-Up: 08/09/03

Posts: 9,270

At 7/16/06 11:40 PM, WoogieNoogie wrote: Now wait right there...wouldn't that be normal HTML inside the noscript tags?

Yup.


None

SplitFusion

Reply To Post Reply & Quote

Posted at: 7/17/06 04:00 PM

SplitFusion LIGHT LEVEL 10

Sign-Up: 08/19/05

Posts: 52

okay. i will say this once and once only.

I AM USING FREEWEBS BECAUSE MY HOME SERVERS ARE MESSED UP.

I WISH TO DEAR SWEET IESHA I DIDN'T HAVE TO, BUT UNTIL I CAN GET MY SERVERS WORKING, I AM TOLERATING IT.

OKAY!


All times are Eastern Standard Time (GMT -5) | Current Time: 08:32 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!