Click to See Complete Forum and Search --> : still fighting with javascript links


qbalance
09-14-2003, 05:15 PM
I'm new at this.
The only javascript I would like to include is

to have specific links on my website
point to other pages in my website or to other websites
When the link is to a different website, I would like a new page to open.

So far I have been told
a. target="new", and target="_blank"
but these give errors

b. I have been told to use certain javascript in my header.
please see
http://www.qbalance.com/QuickBooks_Payroll.htm

While the header may be ontrack, I have not idea what to
include in the following Intuit link to make a new page happen.

<a href="javascript:go('quickbooks.intuit.com/commerce/catalog/product.jhtml?priorityCode=0273400000&prodId=prod5935906')">


c. this code looks like it might be the closest. but when i use it, an error occurs
in the line(s)
self.location="http://www."+dom+loc
else


<script language="javascript"><!--
function go(aID, dom, page){
if(dom=="qbalance.com/")
{
document.getElementById(aID).target="_top";
self.location="http://www."+dom+loc
else
{
document.getElementById(aID).target="_blank";
self.location="http://www."+dom+loc
}
//-->
</script>

and this is the link

<a id="link1" href="java script:go('link1','qbalance.com/','CPA_tips_contact_numbers_and_sites.htm')">


Thank you so much for any assistance you can give.

And if you think its not being a pig to ask one more question
how do I do a javalink to a website that starts with QBA not WWW
There may be 8 links on this page that are www and only a few with qba


Linda Saltz

David Harrison
09-14-2003, 06:08 PM
OK, here's a script, (IE only), that will, onload, go through your a tags and look for the href attribute.
If it finds one it will search the href attribute value for "http:", "www." & "qbd".
If it finds one of those it will create and assign the attribute and attribute value; target="_blank", to the a tag.

A far much easier way would be to go to each link and if you want them to open in a new window, do this:

<a href="http://www.w3.org/" target="_blank">The W3C</a>

And if you don't then leave them as they are:

<a href="index.html">Main Page</a>


This way is probably the best way as it doesn't use JavaScript, and it is also more practical unless you have thousands of links on a page.
I could probably write a JavaScript "debugger" to apply the changes to your source, where you put the source in a textarea and get the new source out the other.

An even better way would be to not open any new windows whatsoever, as it recommends in the WCAG (http://www.w3.org/TR/WAI-WEBCONTENT/#gl-interim-accessibility).

However, for now, here is the IE only script:

qbalance
09-14-2003, 07:04 PM
I've got to leave for a few hours and
wanted to thank you now for your help.

I really appreciate it.

Linda Saltz