PDA

View Full Version : Javascript snipet problem from DW CS3, Open-Window Behavior


theoilman
08-23-2008, 01:13 AM
I am having a problem with code that DreamWeaver (CS3) is writing. I'm fairly certain the problem is in a small piece of JavaScript that DreamWeaver is composing.

This is a fairly complex problem, so bear with me.

First - What I am trying to make happen: When on a page on my site (the-oilman.com) I want a link that opens a new window in the on-line store at a different site (AMSOIL.com). I need to leave both the page on my site open and have this 'store' page open. First of all this is working fine, using the 'Open Window' 'behavior' in DreamWeaver. If someone wants to change windows (or tabs) and go back to my page, leaving the 'store' window open also - the problem is set up to happen. If from back at my site, you click on the same or a different link that goes back to the 'store' either on the same page or a different page at AMSOIL.com - the 'store' window goes to the correct page, but the 'store' window does NOT come on top. When they click on a link to go back to the 'store' I need the 'store' window to come to the top. If they have previously put something in the cart, and come back and add something else to the cart in the 'store' by coming in from different links on my site the 'store' is working correctly because I leave it open the whole time.

snipets of code that DreamWeaver is writing for my site (the-oilman.com):
from the head:
<script>
<!--
CSAct[/*CMP*/ '129AABC1'] = new Array(CSOpenWindow,/*URL*/ 'http://www.amsoil.com/redirect.cgi?zo=52257&page=store','store',0,0,true,true,true,true,true,t rue,true);
CSAct[/*CMP*/ '129AAC63'] = new Array(CSOpenWindow,/*URL*/ 'http://www.amsoil.com/redirect.cgi?zo=52257&page=store','store',0,0,true,true,true,true,true,t rue,true);
CSAct[/*CMP*/ '10D39F40'] = new Array(CSOpenWindow,/*URL*/ 'http://www.amsoil.com/redirect.cgi?zo=52257&page=storefront/sso','store',0,0,true,true,true,true,true,true,tru e);
/
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>

code from 2 different links that is using this script:
<a href="http://www.amsoil.com/redirect.cgi?zo=52257&page=storefront/sso" target="store" onClick="MM_openBrWindow('#','store','')" csclick="10D39F40">Buy Now</a>
<a href="http://www.amsoil.com/redirect.cgi?zo=52257&page=store" title="AMSOIL Store at AMSOIL.com" target="store" onClick="MM_openBrWindow('http:www.amsoil.com/redirect.cgi?zo=52257&amp;page=store','store','')">On Line Store</a>

I believe what I need is a longer javascript. Instead of just "window.open" I need an "if" but my javascript knowledge is very, very limited.
I need it to first check that if the window named 'store' is open then 'focus' it, or if it is not open to open the window named 'store'.
Will this fix my problem? If so, please help me write the lines of code to do it.
If this isn't the solution, what is the problem and the solution?

A separate question but related: if you look in the two different links codes, in the function call one of them uses a 'null' page reference and the other repeats the full link reference from the href= . Both seem to work, but which is the correct or the preferred syntax. My guess is there are some browsers that this will give a problem, but which way is preferred.