Heya guys, I need help with this script, I can get it to pop up on page load, But cant stop that to make it pop up on a link command.
I have page that loads a Pop up window on load which is DHTML and is dragable.
The script:
<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
<!--
// This script handles the dragging and closing capabilities
// of the DHTML popup
//Declare, set global variables
var selectedObj
var offsetX, offsetY
var divPosX, divPosY
//Set the initial X,Y coords for the popup div
divPosX = 15;
divPosY = 15;
//Detect browser verssion
var IE4
var coll, styleObj
IE4 = (document.all) ? 1 : 0;
if (IE4){
coll = "all.";
styleObj = ".style";
}
//return the DOM reference to the given style
function getObject(obj) {
var objRef
if (typeof obj == "string") {
objRef = eval("document." + coll + obj + styleObj);
} else {
objRef = obj;
}
return objRef;
}
//Close the DHTML popup window
function hideElement(obj) {
divRef = getObject(obj);
divRef.visibility = "hidden";
//event.srcElement.style.cursor = "pointer";
}
//Shift an object to given position
function shiftTo(objRef, Xpos, Ypos) {
objRef.pixelLeft = Xpos;
objRef.pixelTop = Ypos;
}
//Only allow IE4+ to initialise DHTML popup, else display normal HTML popup window
function init() {
if (IE4) {
initEvtHandling();
initDiv('dhtmlpopup');
} else {
showHTMLPopup();
}
}
function showHTMLPopup() {
myWindow = window.open("popupURL","NAME","titlebar=no,HEIGHT=170,WIDTH=180");
myWindow.moveTo(200,200);
myWindow.focus();
}
//Assign the event handlers
function initEvtHandling() {
document.onmouseup = releaseElement;
document.onmousemove = moveElement;
}
//Initialise the div
function initDiv(obj) {
divRef = getObject(obj);
shiftTo(divRef, divPosX, divPosY);
divRef.visibility = "visible";
}
function grabElement(obj,evt) {
selectedObj = getObject(obj);
calculateOffsets(evt);
return false;
}
function calculateOffsets(evt) {
mousePosXRef = window.event.clientX;
mousePosYRef = window.event.clientY;
offsetX = mousePosXRef - divPosX;
offsetY = mousePosYRef - divPosY;
}
function moveElement(evt) {
if (selectedObj) {
mousePosXRef = window.event.clientX;
mousePosYRef = window.event.clientY;
divPosX = mousePosXRef - offsetX;
divPosY = mousePosYRef - offsetY;
shiftTo(selectedObj,divPosX,divPosY);
return false;
}
}
function releaseElement(obj) {
if (selectedObj) {
selectedObj = null;
}
}
//-->
</SCRIPT>
So this how I set it to work= Load onload then go find the JS with pics written doc etc to show if IE4+ in a non window, just pics in the JS file but if the browser doesnt support it, will show the pics in a the size set window.
what I cant seem to work out is how to make that script work on a click.
Help Please
