We help IT Professionals succeed at work.

Firefox new page and jump to bookmark

coolarmani asked

I have been web designing using Internet Explorer for many years. Now due to the growing popularity of the Firefox browser I would like my sites to look and demonstrate the same behaviour on both.

Two things are causing me problems. Firstly when I use the target="_blank" tag in IE it opens in a new window (as desired) however in Firefox it opens in a new tab. This is not what I wish to happen. How can I make it open in a new window?

Also in IE on one of my pages as soon as it loads it jumps to a bookmark further down the page (as desired) however in Firefox the bookmark is ignored and it starts at the top of the page. How do I make it jump straight to the bookmark?

Any ideas folks?
Watch Question

Expert of the Year 2008
Top Expert 2008
>>Firefox it opens in a new tab
This is because the browser is configured to open "new windows" in a tab rather than a new browser instance. It's a user preference, which you cannot change programmatically. If anything you might want to try:
<a href="http://somesite.com" onclick="window.open(this.href,'blank','scrollbars=1')>Resources</a>
Look up the options (third argument) to window.open().

>>however in Firefox the bookmark is ignored and it starts at the top of the page
Last time I tested this, it worked perfectly fine. You just need to make sure that:
a. the "bookmark" exists
b. you added the "bookmark" to the end of the url. Ex: http://somesite.com/index.html#resources
3. you spelled the "bookmark" exactly as specified on the HTML code. #bookmark and #Bookmark are not treated the same


Thanks for the reply and for confirming my suspicions that it was not possible to overrule default firefox settings. (new page in new window/tab).

The second is basically as I was already doing but I have now managed to solve the issue.

I needed to add an additional:-
<script>window.location.href = "#bookmark";</script>

I already had one positioned just after the <BODY> tag but I needed to add another just before the </BODY> tag. If I only had the one after the <BODY> it would not work in Firefox and if I only had the one before the </BODY> tag it would not work in Internet Explorer. By including both it now works on both browsers.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.