• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Using javascript to modify browser navigation barcontent

fender

Limp Gawd
Joined
Mar 2, 2003
Messages
417
Is it possible to add something to the URL in browser navigation bar with javascript? Something like...

var url = document.URL + '/text';
document.navbar.write(url);
 
are you attempting to change the navbar without actually refreshing the page? If so, then no.

otherwise you can just change the location i.e. window.location = 'newurl';
 
window.location.href='newpage.htm' is probably what you're looking for.

it will take the user to newpage.htm. as for actually displaying the new link in the navbar without going to the new page first, i don't think that's possible (it will display it in the navbar once you do get to the new page though). But then again, i've seen all kinds of bizzare stuff done with javascript.
 
I need to emulate clicking on a link without actually doing so. I want the address in the navbar to change withough actually reloading or loading a new page. Sounds like it can't be done though.
 
I'm thankful that you can't do it.

Consider:

document.navbar.write("https://citibank.com/login/");
 
OK, how about this...

Could it be possible to add '/whatever' to the end of a url? Something like href="/whatever" but without actually taking you there. I'm guessing the answer is no...
 
fender said:
OK, how about this...

Could it be possible to add '/whatever' to the end of a url? Something like href="/whatever" but without actually taking you there. I'm guessing the answer is no...

sure, you can do that

E.g. change the link from cnn.com to msn.com. Change both the href and the actual link text itself.
Code:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Change linky</title>
<script language="javascript" type="text/javascript">
function changeLink(linkID,newURL,newText)
{
	document.getElementById(linkID).innerHTML = newText;
	document.getElementById(linkID).href = newURL;
}
</script>
</head>

<body>
<a href="#" onclick="changeLink('theLink','http://msn.com','MSN');">Click Here to change the Link</a><br />
<a id="theLink" href="http://cnn.com">CNN</a>
</body>
</html>
 
Thanks for the reply but I think you misunderstood me. When you click a link like this

<a href="#link">click me</a>

the URL in the navbar becomes http://localhost/link.html#link and no new page is loaded. What I want is the same thing to happen, but instead of having '#link', I would like to have '/link'. I'm 99% sure this can't be done since having '/link' appended to the end of the url will automatically take you to that location.
 
fender said:
Thanks for the reply but I think you misunderstood me. When you click a link like this

<a href="#link">click me</a>

the URL in the navbar becomes http://localhost/link.html#link and no new page is loaded. What I want is the same thing to happen, but instead of having '#link', I would like to have '/link'. I'm 99% sure this can't be done since having '/link' appended to the end of the url will automatically take you to that location.

nope.. can't be done. just the thought of the security risks involved with allowing something like that makes me shudder.
 
fender said:
Thanks for the reply but I think you misunderstood me. When you click a link like this

<a href="#link">click me</a>

the URL in the navbar becomes http://localhost/link.html#link and no new page is loaded. What I want is the same thing to happen, but instead of having '#link', I would like to have '/link'. I'm 99% sure this can't be done since having '/link' appended to the end of the url will automatically take you to that location.



take out the href property of the anchor tag

<a onclick="javscript....">click me</a>
 
maxedoutcc said:
take out the href property of the anchor tag

<a onclick="javscript....">click me</a>


you missed the point too. i believe he wants the url to change in the address bar of the browser when he clicks on it. though he calls it the navbar, which is a little bit confusing.
 
maw said:
you missed the point too. i believe he wants the url to change in the address bar of the browser when he clicks on it. though he calls it the navbar, which is a little bit confusing.
<body onload=""> ?
 
Back
Top