|
Post by .hp_pickle on Sept 21, 2005 0:21:37 GMT
Suppose you have a new page for an RPG code or something but the title says "Your Forum - Home" So you would need to change it to something else. <script language="javascript"> var newTitle = 'New Title'; var pageTitle = document.title; var splitTitle = pageTitle.split(" - "); document.title = splitTitle[0]+' - '+newTitle; </script> This is pretty simple. You define the new title, grab the page title using document.title, split it with the - (title - home). So splitTitle[0] would be title and splitTitle[1] would be the Home thing. You take the first page, your forum name/title and you add the new title after the -. So now you could have "title - New Title" Edit: Inappropriate variable names
|
|
|
Post by [dmsuperman] on Sept 23, 2005 2:17:14 GMT
1) Put it in code submissions 2) Use title as the var name 3) You don't want to use the explode[0] as the title, what if the title of the site is "blah-whatever" then it assumes blah is the whole title. Split them all and just delete the last one.
|
|
|
Post by california on Sept 23, 2005 23:40:01 GMT
1) Put it in code submissions This is an open source script and belongs here. It wouldn't be accepted if it were posted in the code submission board.
|
|
|
Post by Shin™ on Sept 24, 2005 5:47:21 GMT
2) Use title as the var name Why? His var names are fine.
|
|
|
Post by california on Sept 24, 2005 10:45:15 GMT
'title' should not be used as a variable name, it is a predefined property and thus a reserved word. JavaScript will let you get away with it because of its flexibility but you still shouldn't.
|
|
|
Post by .hp_pickle on Sept 24, 2005 15:15:29 GMT
Okay, I'll change it then.
No wait, the variables are all splitTit, newTit, etc.
|
|
|
Post by california on Sept 27, 2005 4:30:52 GMT
I was responding to this: 2) Use title as the var name Your variable names are inappropriate for a different reason
|
|
|
Post by I'm a Kuzu - Uzukami on Sept 27, 2005 21:12:34 GMT
XD So I wasn't the only person to notice that?
|
|
|
Post by .hp_pickle on Sept 27, 2005 23:24:39 GMT
I was responding to this: 2) Use title as the var name Your variable names are inappropriate for a different reason Oh ... then why is it inappropriate then?
|
|
|
Post by James on Sept 27, 2005 23:27:37 GMT
I was responding to this: Your variable names are inappropriate for a different reason Oh ... then why is it inappropriate then? Because, the number of times "tit" appears in there is surpassed only by Girls Gone Wild.
|
|
|
Post by .hp_pickle on Sept 28, 2005 0:47:39 GMT
Oh ... then why is it inappropriate then? Because, the number of times "tit" appears in there is surpassed only by Girls Gone Wild. Oh.... *edits* heh... didn't realized that.
|
|
|
Post by california on Sept 28, 2005 1:56:57 GMT
Plus splitTit gives a really bad image...
|
|
|
Post by .hp_pickle on Sept 28, 2005 2:39:05 GMT
Plus splitTit gives a really bad image... ahem... hehehe
|
|
|
Post by egbakaet :D on Sept 30, 2005 23:18:22 GMT
Plus splitTit gives a really bad image... I read the wrong thread, wrong time.
|
|
|
Post by .hp_pickle on Oct 1, 2005 5:31:34 GMT
Plus splitTit gives a really bad image... I read the wrong thread, wrong time. I made the wrong code, wrong time. I smile everytime I think about split tit...
|
|
|
Post by Luke on Oct 13, 2005 0:24:28 GMT
Nice job there Hp. I am proud!
|
|
chemdude
Full Member
2B || !2B
Posts: 228
|
Post by chemdude on Oct 13, 2005 0:43:52 GMT
'title' should not be used as a variable name, it is a predefined property and thus a reserved word. JavaScript will let you get away with it because of its flexibility but you still shouldn't. I think also goto and lbl and some other things are also reserved too.
|
|