for firefox brwoser
I need place a script inside my page , and when visitors click on links , it open new windows
| SitePoint Sponsor |
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.
Code javascript: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; } }
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript


The following should do it. Place this just before the </body> tag.
Code javascript: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; } }
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
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.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript

Perhaps you don't have Firefox configured to allow a web page to open a new window.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
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.
Code html4strict:<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.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
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.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
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
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
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.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
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
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
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.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Bookmarks