Chris, I had exactly the same issue and this was the solution I found.
Essentially it's a script to open all external links in a new window with a
slight modification to recognise a substring in a form tag and do likewise.
Anyway, here's the JavaScript:
// JavaScript Document
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
var forms = document.getElementsByTagName("form");
for(var i = 0; i < forms.length; i++)
{
var form = forms[i];
if(form.getAttribute("id").substring(0, 6) == "paypal")
{
form.target = "_blank";
}
}
}
____________________________________________________________
You'll need to put the script in the head tag or link to it:
<script type="text/javascript" src="links.js"></script>
.... and add trigger it onload in the body tag :
<body onload="externalLinks();">
After that, any link with rel="external" in the href tag or any form with
id="paypal" in the form tag will open in a new window and the code will
validate as XHTML strict.
It worked for me. Hope it helps.
I wish I could remember where I found it, but I can't. There are a few more
similar scripts out there.
Andy
-----------------------------
Andy Woznica
Actofdesign
http://www.actofdesign.com
On 11/12/06 12:57 PM, "Chris Price" <[EMAIL PROTECTED]> wrote:
> Hi
>
> I have a little online store paying through Paypal, using their
> shopping cart. So the buy button opens up a new window and you're into
> Paypal.
>
> Unfortunately the bit of html for the form uses 'target' to open up the
> window and I'm coding in xhtml strict.
>
> I'm using onclick="newWindow() return false" for opening new windows.
>
> I'm looking for a simple bit of javascript to do the same for the form,
> something like form.target = window.open()
>
> Any ideas?
>
> Kind Regards
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************