I just needed a fast and easy way to add a popup window. Any where that I could place a link.
Just for easy setup I place this file in includes/templates/YOUR_TEMPLATE/common/popup.php
But you can place it anywhere you want you just have to add the path to the include statment.
Just copy the code below and save it as popup.php
PHP Code:
<?php
/**
* popup.php
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
*
* Standards Compliant Popup Script
* Author : Kevin Cannon
* http://www.multiblah.com
* Last Edited: 12.12.2004
* Version 1.0
*
* SkipWater adapted for zen cart 10.15.09
*
* Searches through a document for links with the class popup.
* When clicked, this link will open in a popup window.
* This means you don't have to add javascript to your code,
* and means the links continue to work, for search engines,
* and browsers without javascript.
*
*/
?>
<script type="text/javascript">
function initPopups() {
if (!document.getElementById) return
var aLinks = document.getElementsByTagName('a');
for (var i = 0; i < aLinks.length; i++) {
if (aLinks[i].className == 'popup') {
aLinks[i].onclick = function() {
var url = this.href;
openPopup(url);
return false;
}
}
}
}
// popupWindow function
// This is where you set your specific height & width etc... for your popups.
function openPopup(url) {
window.open(url, 'popupwindow', 'width=640,height=500,scrollbars,resizable');
return false;
}
// Piggy-back fucntion onto onLoad event
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
addLoadEvent(initPopups);
</script>
Add this include link to your includes/templates/YOUR_TEMPLATE/common/html_header.php just before </head> tag.
PHP Code:
<?php include("popup.php"); ?>
To call the popup with a link
PHP Code:
<a class="popup" href="path_to_it/pdf_file.pdf">A PDF File or any file you want in the popup window</a>
That's it
Skip