Add Your Own Javascript Popup Window Code

Re version 2.0.13

We have some images and links that needed to open into their own popup window. For example, we wanted the godaddy SSL seal and some other external websites to open within their own popup windows - so viewers don’t accidently leave our site. My popup “script” is in a [MyFileName].js file and I wanted to know WHERE to [properly] put the .js file so that when cs-cart updates are released my custom code isn’t overwritten or something else gets screwed up (no time for monkey wrenches in the gears and the associated stress). I sent a support request to tech support asking how to do this correctly. So, for all you folks wanting to add your own custom popup script [yourfile].js files and calling them correctly, without going through HOURS of studying how to do it, here’s HOW to correctly do it. By the way, below is my exact question to support and their instructions.

[quote]MY QUESTION TO SUPPORT…

Our “Store Security” page (located in the cart “information” box [URL]http://www.supremefulvic.com/store/index.php?dispatch=pages.view&page_id=5[/URL]) has a GoDaddy image that when clicked on is supposed to open up a new window using javascript. However, I have been trying (for hours) to figure out how to incorporate the related “docWindow.js” file! I give up trying to figure it out.

So, here I am. Where/how do I put this link: ?

Thanks – Bill G, Manager



SUPPORT RESPONSE

Please try to insert the mentioned line of the code the following way:

  • Create the “my_changes/hooks/index” directory path in the “skins/[yourskin]/customer/addons” directory of your CS-Cart installation.
  • In this new “skins/[yourskin]/customer/addons/my_changes/hooks/index” directory create the “scripts.post.tpl” file with the following content:


- Clean up the template cache by opening the following link: [U][url]http://www[/url].[yourCS-CARTstoreLocaton]/index.php?cc[/U]
[/quote]

Here is the .js script I use to open the window

This script...

<-- BEGIN SCRIPT -- >
var win = null;
function docWindow(mypage,myname,w,h,features) {
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/6;
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}
<-- END SCRIPT -->

...is within a file [yourFileName].js

Place this code within the body of your HTML page wherevery you need it:
<-- BEGIN CODE -->
YOUR IMAGE OR LINK HERE
<-- END CODE -->

Note: Change "SSL" to whatever you want to name your popup window.

Hope this is helpfull.
Bill G.

Thanks Bill,



I wanted this, thanks for your time





John

Thank for this! this what we loking for



I want ask How to make pop up as ebay did



as i see cscart made - show pop-up for 5 seconds after add product



but I want use that for firsttime visitor come my site to choise currency that might they use and then save it to log/cookies(i dunno what right name of it) as example ebay did. when we look product - pop-up come and choise the country - if i choise county : singapore the price product change from US to SGD



Hope you understand my english. Thanks