View Full Version : How to prevent navigation tools from disappearing

Sep 19th, 2007, 05:07 PM
I have the following problem: There is a site (not mine) which links to my own site, but it does that in such a way that my site opens in a new window without navigation tools such as the toolbar, menubar and location field. It does that with the window.open command and the corresponding attributes set to 0.

This is of course very annoying and probably not what most visitors of my site want. Unfortunately most people reach my site via his site. I asked him several times to change his link, but for some reason itís like Iím talking to a wall. So, I am now looking for a javascript solution to restore the navigation tools from within my own site. I tried the following code:

<script>function showNavigation()

<body onload="javascript:showNavigation()"> ... <body>

But this doesnít seem to work. Am I doing something wrong or is there somebody who has a better solution to prevent the navigation tools from disappearing? Thanks.

Philip M
Sep 19th, 2007, 06:40 PM
"Unfortunately most people reach my site via his site. I asked him several times to change his link, but for some reason it’s like I’m talking to a wall."

That's tough, but nothing can be done. JavaScript cannot function in a different domain.

Sep 19th, 2007, 09:01 PM
No, you got me wrong. I know javascript doesn't work in a different domain. What I am trying to do is to put code on my own page that would restore the navigation tools once it has opened in its own window. I am not trying to access or change the code on the page that is linking to my website.

The idea I have in mind is that when my own site has opened in its own window, it would detect somehow that the navigation tools are invisible and then would run a small javascript to make them visible again. Or even better, to prevent the tools from being hidden in the first place.

Sep 19th, 2007, 09:47 PM
You could try asking for permission to show/hide window elements.
see http://developer.mozilla.org/en/docs/DOM:window.statusbar for an example.

Another alternative would be to check to see if his site is the referrer and open your own window (the way you want it) then close his.

Sep 20th, 2007, 01:09 AM
Is your page made in frames so that he is lining to the page that doesn't have the nav??

There used to be a script in dynamic drive which could force your page to be loaded back into a framed page. It was like the reveres of break out of frames. maybe that would help? Alternatively, you might want to look into making your page 'all one' so that whatever is loaded, is actually the whole page.

I am assuming that when they view your page, it is being viewed on your server directly and not, within a framed page of the referer site.

it may be helpful if we had a link to your page and also to the page in this other site, which links to yours.

Sep 20th, 2007, 04:28 AM
JavaScript can't affect the content of the browser chrome 9the part surrounding the web page) except during the window.open() call where it can suggest how the new window should look. People can set their browser to disregard the settings sufggested by window.open() but only extremely old browsers that are full of security holes will allow the page to update the current browser appearance (even IE stopped allowing it several versions back).

Sep 20th, 2007, 02:17 PM
Thank you. I think I have found a way to get this done. I was inspired by the alternative suggestion from eak to check the referrer and open my site in a new window. The problem is that the site that links to my page uses a contruct that leaves the referrer undefined, so I could not use it. This is his link:

<a href="http://MySite.com/" onkeypress="window.open(this.href,'window','toolbar=0, status=1,scrollbars=1,resizable=1,location=0,directories=0,copyhistory=0,menuBar=0,width=0,height=0' );return(false);" onclick="window.open(this.href,'window','toolbar=0, status=1,scrollbars=1,resizable=1,location=0,directories=0,copyhistory=0,menuBar=0,width=0,height=0' );return(false);">Link to my site</a>

Instead of opening my own window the way I want it and closing the other instance I did it the other way around. When a site links to my site and opens it in a new window it sends the URL back to the opener, so my site re-opens in the window of the referrer while closing the newly created window, leaving the history intact and all the navigation tools as they were, so there is also no danger of conflicting preferences in the browser settings. I used the following code:

<script type="text/javascript">
opener.location = location.href;

I post my solution because it might be helpful to other people as well. As I was inspired by eak's suggestion my thanks point goes to him.