New windows for firefox

for firefox brwoser
I need place a script inside my page , and when visitors click on links , it open new windows

The following should do it. Place this just before the </body> tag.


document.body.onclick = function (evt) {
    evt = evt || window.event;
    var targ = evt.srcElement|| evt.target;
    if (targ.nodeType === 1 && targ.nodeName === 'A') {
        window.open(targ.href);
        return false;
    }
}

The following should do it. Place this just before the </body> tag.


document.body.onclick = function (evt) {
    evt = evt || window.event;
    var targ = evt.srcElement|| evt.target;
    if (targ.nodeType === 3) {
        targ = targ.parentNode();
    }
    if (targ.nodeType === 1 && targ.nodeName === 'A') {
        window.open(targ.href);
        return false;
    }
}

unfortunately it didnt works

Where and how are you adding it to the page? A link to the non-working page will help a lot too.

Perhaps you don’t have Firefox configured to allow a web page to open a new window.

Here
http://www.antiagingplan.net/test3.htm

It doesnt open new windows for firefox

Well at first glance, that onclick event most definately is illegal.


<a ... onclick="function (evt)">

No wonder Firefox is having conniptions trying to interpret what is within that statement. Get rid of it, and try again.

Done
not useful yet

Have you forced a refresh with Ctrl+F5, and checked the source to ensure that the onclick event is no longer there?

It works for me in Firefox now.

sure i did it
i mean new windows Not new tab

i am using firefox version 3.0.19

There is no control over whether a user’s web browser opens a new window as a tab or as a window.
It is only the individual user’s web brower settings that detemine that.

In Firefox, see Tools -> Options -> Tabs

If i remove target=_blank it doesnt open no new tab no new windows

what this script do on your browser?

The test page doesn’t appear to have updated yet.

Deleted target=_blank now

The script is running too early. When it runs from the head, there is no document.body that yet exists.

Place the script to just before the </body> tag, as I stated in my first post to this thread at post #2

Yes i see
Is there anyway to setup it for open new windows not new tab ?

No. We used to, but abuse of pop-overs and pop-unders became such a nightmare for the user, that the web browsers removed that type of control from scripting. You have no control over that aspect of the users web browser.

If the user wants new windows to open in a new window instead of a new tab, they will have to either set up their web browser to do that. Either that, or the user will have to manually right-click on the link and select to open it in a new window or a new tab.