Click to See Complete Forum and Search --> : Seeking Popup Script Help


Resource
05-21-2003, 12:12 AM
I found a JS I would like to use, I've got it working online with no problems. However I really don't want it to disable the right click functions, On a right click event I just want it to pop up the custom HTML message page where I want it and leave the right click user functions 100% functional.

What do I need to change in this code to accomplish this?

Would I be better off starting from scratch or does another script already exist that does what I want more effeciently?

I understand about half of what's going on in this script but simply don't know enough JS yet, besides time is in very short supply if you know what I mean, otherwise I wouldn't be asking.

TIA for your help, Jim
Code below:

<script language="JavaScript">
<!--
// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header.

// ----------- Setups ------------------
// Set the address, width, height, top
// and left dimensions for the popup
// window below.
// -------------------------------------

PopUpURL = "http://d3901543.u50.infinology.com/CopyPopup.htm";
PopUpLeft = 200;
PopUpTop = 200;
PopUpWidth = 330;
PopUpHeight = 220;

// -------------------------------------
// Do not edit anything below this line.
// -------------------------------------

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
popO='left='+PopUpLeft+',top='+PopUpTop+',width='+PopUpWidth+',height='+PopUpHeight

if (isIE||isNN){
document.oncontextmenu=checkV;
}else{
document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
document.onmousedown=checkV;}

function checkV(e){
if (isN4){
if (e.which==2||e.which==3){
dPUW=window.open(PopUpURL,'nrc',popO);
return false;
}}else{
dPUW=window.open(PopUpURL,'nrc',popO);
return false;}}

function MM_popupMsg(msg) { //v1.0
alert(msg);
}
//-->
</script>

FUNCTIONING EXAMPLES:
http://d3901543.u50.infinology.com/Index.htm
http://d3901543.u50.infinology.com/Newsletter1.htm

Popup HTM file:
http://d3901543.u50.infinology.com/CopyPopup.htm

havik
05-21-2003, 12:36 AM
I looked the pages and am kinda confused as to what you want to happen. I'm guessing you want the pop up window to display but also keep the right click menu? If this is the case, isn't it redundant to have a copyright notice?

BTW, the right click script doesn't work for Opera 7.1 and no other scripts have worked for Opera that I've seen.

Havik

Resource
05-21-2003, 08:45 AM
Havik,

Thanks for your reply. Youve got it, on a right click I want the popup notice to display as well as the windows default right click menu. The popup can disappear after 3 to 5 seconds leaving the menu or it (the popup notice) can disappear as soon as the user selects an item from the default menu in other words, on the next mouse down event, either way would do the trick. here's a picture of what I would like to see on a right click event:

http://d3901543.u50.infinology.com/RightClickSample.jpg

I hope this helps, Jim

havik
05-21-2003, 08:12 PM
Here is the code that calls the pop up menu on a right click, the menu isn't disabled on IE6.

<script type="text/javaScript">

///////////////////////////////////
function clickIE4(){
if (event.button==2){
return true;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
return true;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("window.open('ENTER YOUR COPYPOPUP.HTM FILE HERE','','width=310, height=194, scrollbars=no, toolbars=no, resizeable=no');return true")

// -->
</script>

In your CopyPopup.htm file, the following code will close the window after 5 seconds. Change to 3000, etc... for other times.

<script type="text/javascript">

setTimeout('window.close()', 5000);

</script>

Havik

Resource
05-21-2003, 10:15 PM
Havik,

Awesome, works like a champ! I'll play with the positioning a little bit. It never occured to me to put the code in the file being called, duhhhhhh, it makes perfect sense.

I owe you one! If ever you need let me know and I'll do what ever I can. Good job, I really like the way you simplified the script. the logic is straight forward.

Can't sing your praises enough, thanks a million, Jim

havik
05-22-2003, 12:34 AM
Thanks for the comments (**blushes** :D)

If you need any more help with the code let me know.

Havik