BleepingComputer.com: Multiple titles in one page???

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Multiple titles in one page??? HELP

#1 User is offline   Super Panda 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 269
  • Joined: 23-April 08
  • Gender:Male
  • Location:Leicester

  Posted 10 April 2009 - 12:36 PM

Hi, I am developing a site for my online buisness and I wanted to have lots of page titles in one.

My son plays Habbo and he was on a site which looked pretty impressive!

The site is habborator.org and everytime you refresh it notice the The title at the top changes.

So for BC it is BleepingComputer.com all the time but with this HTML code or some sort of script you could make it different everytime it is opened.

EG

BleepingComputer
REFRESH
BC --> For all your computing needs
REFRESH
BC --> Most active computing forum on the net...

Thanks and anyone?????
...

#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 10 April 2009 - 01:02 PM

I don't see a title. I see a scrolling marquee. Is that what you are talking about?
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   burn1337 

  • Forum Regular
  • Find Topics
  • Group: Banned
  • Posts: 311
  • Joined: 07-March 09
  • Gender:Male

Posted 10 April 2009 - 07:08 PM

I see what you are talking about.... What you could do is either using php, or javascript... You can either set a numbered variable in a session, or a cookie... Or even have a random number generated each time the page is loaded, and then use a switch statement to switch between titles... For instance with php(this would have to be ran wile the script is still in the header before you open the body tags):
$TInt = rand(1, 8);
switch($Tint) {
case 1:
   echo "<title>Hello</title>";
   break;
....
default:
	echo "<title>Have a nice day</title>";
	break;
}


Now with javascript you can either set a random number, also if I remember correctly you do not need to set this one in the headers of the script, also seeing as Javascript is action script, you could also create a loop that waits for a certain amount of seconds changes the number and switches for the result (not sure what the function for that would be though)...
var TInt = rand(); //or any other method
switch(TInt) {
  case 1:
	document.title('Hello'); //It might be a different name for the document object to write to the title...
	 break; 
}

This post has been edited by burn1337: 10 April 2009 - 07:09 PM


#4 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,834
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 11 April 2009 - 01:11 AM

I would make a function to randomly select title of page and use SetInterval() to call it repeatedly.

//titles function chooses a random title
function titles(){
	var r = Math.floor(Math.random() * 3.0); //generates random number between 0 and 2
	var t = "";
	//select a title depending on random number	   
	switch(r){
		case 0 : t = "Welcome"; break;
		case 1 : t = "Goodbye"; break;
		case 2 : t = "Hello"; break;
		default: t = "Goodnight";
	}
	document.title = t; //set the title of current page
}
setInterval("titles()",1000); //calls the titles() function every 1000 milliseconds (1 second)

This post has been edited by Romeo29: 11 April 2009 - 01:15 AM


#5 User is offline   burn1337 

  • Forum Regular
  • Find Topics
  • Group: Banned
  • Posts: 311
  • Joined: 07-March 09
  • Gender:Male

Posted 11 April 2009 - 01:30 AM

Romeo - Thanks for correcting my Javascript, it has been awhile since I have actually done anything with it...

(btw people, my scripts where just sample/examples lol)

#6 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,834
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 11 April 2009 - 02:05 AM

View Postburn1337, on Apr 11 2009, 01:30 AM, said:

Romeo - Thanks for correcting my Javascript, it has been awhile since I have actually done anything with it...

(btw people, my scripts where just sample/examples lol)


I know :thumbsup: Your code has a taste of PHP.

#7 User is offline   burn1337 

  • Forum Regular
  • Find Topics
  • Group: Banned
  • Posts: 311
  • Joined: 07-March 09
  • Gender:Male

Posted 11 April 2009 - 05:15 PM

Yea well, I have been doing everything in php lately... By the way I am almost done with the re-vision of my site... YAY lmao

#8 User is offline   Super Panda 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 269
  • Joined: 23-April 08
  • Gender:Male
  • Location:Leicester

Posted 03 May 2009 - 10:06 AM

View PostRomeo29, on Apr 11 2009, 07:11 AM, said:

I would make a function to randomly select title of page and use SetInterval() to call it repeatedly.

//titles function chooses a random title
function titles(){
	var r = Math.floor(Math.random() * 3.0); //generates random number between 0 and 2
	var t = "";
	//select a title depending on random number	   
	switch(r){
		case 0 : t = "Welcome"; break;
		case 1 : t = "Goodbye"; break;
		case 2 : t = "Hello"; break;
		default: t = "Goodnight";
	}
	document.title = t; //set the title of current page
}
setInterval("titles()",1000); //calls the titles() function every 1000 milliseconds (1 second)


How do I go about installing that onot my server?
...

#9 User is offline   Stofzuiger 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 332
  • Joined: 06-March 09
  • Gender:Male
  • Location:The inside

Posted 03 May 2009 - 10:33 AM

Quote

How do I go about installing that onot my server?


You implement in the code you want to =']
Every one goes fun fun fun
Who is this doin' this synthetic type of alpha beta psychedelic bleepin'? ~Chemical Brothers - Elektrobank

#10 User is offline   Super Panda 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 269
  • Joined: 23-April 08
  • Gender:Male
  • Location:Leicester

Posted 03 May 2009 - 12:13 PM

View PostStofzuiger, on May 3 2009, 04:33 PM, said:

Quote

How do I go about installing that onot my server?


You implement in the code you want to =']


yes... but where in my document :@
...

#11 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 03 May 2009 - 04:55 PM

Where do you usually put your script?
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#12 User is offline   Super Panda 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 269
  • Joined: 23-April 08
  • Gender:Male
  • Location:Leicester

Posted 13 May 2009 - 05:38 AM

On my actual directory,

You see I want multiple titiles, but I wouldnt know howto make this script work, any help?
...

#13 User is offline   TheStalker 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 55
  • Joined: 16-September 08

Posted 13 May 2009 - 10:19 AM

not really tested but off the top of my head prob just some thing like this

$title1 = "Page title 1";
$title2 = "Page title 2";
$title3 = "Page title 3";
$title4 = "Page title 4";
$title5 = "Page title 5";

$random = rand(0,4);
if($random ==0)
{
	$title = $title1;
}
else if ($random == 1)
{
	$title = $title2;
}
else if ($random == 2)
{
	$title = $title3;
}
else if ($random == 3)
{
	$title = $title4;
}
else if ($random == 4)
{
	$title = $title5;
}


?>
<html>
<head>
<title> <?php echo $title;?> </title>

</head>
</html>

This post has been edited by TheStalker: 13 May 2009 - 10:21 AM


#14 User is offline   Super Panda 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 269
  • Joined: 23-April 08
  • Gender:Male
  • Location:Leicester

Posted 14 May 2009 - 05:00 PM

Yes, but how do I make it work on my website?

Its alright having the code but I dont know where it should go... Head? footer , body!

Thanks
Jake
...

#15 User is offline   Super Panda 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 269
  • Joined: 23-April 08
  • Gender:Male
  • Location:Leicester

Posted 14 May 2009 - 05:07 PM

Because, I am not good with website coding whatsoever, I just get by
...

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users