/    Sign up×
Community /Pin to ProfileBookmark

need help with simple javascript

hi

i was wondering if there is a way to combine this

[code]
javascript:(function() {document.title=(“tab name”);})()
[/code]

and

[code]
javascript:document.location.href = ‘http://www.whatever.com’
[/code]

in the navigation line on my browser

if for example i want to go to some webpage and the tab in my browser will be named after it
i want the tab to be changed to what i specify and the page will be the same website

help will be appreciated
tnx in advance

to post a comment
JavaScript

14 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 03.2009 — combine what? I don't see a standard javascript code there. On which event? When?
Copy linkTweet thisAlerts:
@Declan1991Jul 03.2009 — Well you could combine them technically, but no action on page one will load page two and change the name of it.
Copy linkTweet thisAlerts:
@pendiehoauthorJul 03.2009 — Well you could combine them technically, but no action on page one will load page two and change the name of it.[/QUOTE]

ok, what i meant was there commands are strings for browser address line not for a page or a website that i need to include these strings in

i was wondering if there a way to write "combine" these two

into one command/string

i have little knowledge in javascript so you might find me difficult explaining what i really mean

i just want a script that loads a website and renaming the tab instead getting the name from the page title

like if you paste javascript?function() {document.title=("tab name");})()

after you loaded a webpage in a tab the tab will be renamed to whatever you inserted as document.title

so basicly this is it

thanks in advance :>
Copy linkTweet thisAlerts:
@ReisJul 03.2009 — maybe something like this:

function changePage(url,title) {

window.location = url;

document.title = title;

}
Copy linkTweet thisAlerts:
@pendiehoauthorJul 04.2009 — thats not what i meant, i meant a script that will take me to a specific site and will rename the tab name.

i need a script not for a html or php, i need a line that i can paste in the address bar of my browser Firefox, IE etc etc...

similar to what i posted earlier.

if someone could help me with that i will be grateful.:rolleyes:
Copy linkTweet thisAlerts:
@ReisJul 04.2009 — i dont quite understand what u mean. The function i gave u should do just that. It will take you to a page and rename the tab. just simply use changePage('www.whatever.com','tab name') on any link.
Copy linkTweet thisAlerts:
@Declan1991Jul 04.2009 — thats not what i meant, i meant a script that will take me to a specific site and will rename the tab name.[/QUOTE]
I explained that, but I'll say it again. You cannot.
Copy linkTweet thisAlerts:
@pendiehoauthorJul 05.2009 — I explained that, but I'll say it again. You cannot.[/QUOTE]

why not?

isnt there a way to do so i mean load a page and rename the title to whatever

tnx
Copy linkTweet thisAlerts:
@MalgrimJul 05.2009 — I suppose the guys implementing JavaScript probably figured, that people wouldn't want other people to change their websites.
Copy linkTweet thisAlerts:
@ScriptageJul 05.2009 — You could have a server side program that takes a URI and a title and prints out a frameset:

Perl code:

[code=php]
#!/usr/bin/perl -w

use CGI;
use strict;

my $query = new CGI;
my ($page, $title);

print $query->header;

if($page = $query->param('page') && $title = $query->param('title')){

print<<FRAME;
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>$query->param('title')</title>
</head>
<frameset cols="100&#37;">
<noframes>
To be viewed properly, this page requires frames.
</noframes>
<frame src="$query->param('page')" />
</frameset>
</html>
FRAME

}else{

print<<STANDARD;

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Invalid argument</title>
</head>
<body>
<div>
Not enough arguments passed.
</div>
</body>
</html>
STANDARD

}
[/code]


Then in Javascript, var url = '/cgi-bin/program.pl?page=' + escape('http://www.someite.com/somepage.html') + '&title=' + escape('My page title!');
Copy linkTweet thisAlerts:
@Declan1991Jul 05.2009 — why not?[/QUOTE]
Because JavaScript is client-side, it only operates on that page, at that time. It does not last between pages.
Copy linkTweet thisAlerts:
@pendiehoauthorJul 05.2009 — [B]Scriptage[/B]

i know how to make a frameset, im currently working on app, cpp app

Because JavaScript is client-side, it only operates on that page, at that time. It does not last between pages.[/QUOTE]

and i dont need for it to last i just need for it to load a url alo.blabla.com

and rename the title to blablabla

only for the current url im not planning for it to be changed or browse the website without the tab being changed by page

i just want it to be renamed once and thats it im sure there is a sinple string for that to be loaded straight trough browser address line
Copy linkTweet thisAlerts:
@Declan1991Jul 05.2009 — and i dont need for it to last i just need for it to load a url alo.blabla.com

and rename the title to blablabla[/QUOTE]


I'll say it one more time anyway, once the second page loads, you are starting afresh. They cannot be combined into one step through JavaScript.
Copy linkTweet thisAlerts:
@pendiehoauthorJul 05.2009 — I'll say it one more time anyway, once the second page loads, you are starting afresh. They cannot be combined into one step through JavaScript.[/QUOTE]

ok, tnx ?
×

Success!

Help @pendieho spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...