Forum Moderators: open

Message Too Old, No Replies

Help Coding Link, Please

Need some simple help to properly code a link

         

jon5858

5:19 pm on Apr 24, 2002 (gmt 0)



Hello,

I'm adding an exit popup that only appears when visitors leave my site. As such, I need to code all my internal links with onclick="exit=false"

That's easy enough, but I'm using a dropdown menu script (Ultimate Dropdown Menu) and I can't just code the links in the script. I e-mailed the developer and he sent this back as the proper format for coding the link:

("page.html?name=value&othername=othervalue")

I'm ignorant about how to translate this. He's a busy guy and takes a while to respond, so I thought I'd just ask you helpful folks. Can someone please take the onclick="exit=false" instruction and put it in the proper format for me?

Thanks very much in advance!

jatar_k

5:24 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



welcome to webmasterworld jon5858

I think i see what it means but a little more info might be good. Do the links in the dropdown menu get fired by an onChange event or is there a button you click to GO to the link?

if it calls a function you may be able to put your exit=false into the function itself.

jon5858

5:30 pm on Apr 24, 2002 (gmt 0)



Thanks for the reply, Jatar.

It's a DHTML dropdown menu, in which the user simply clicks the link name to go to that page.

Here's a bit more of the code from the script that shows how each page is linked:

// add main link item ("url","Link name",width,"text-alignment","_target","alt text",top position,left position)
addMainItem("index.html","Home",115,"center","","",0,0);

// define submenu properties (width,"align to edge","text-alignment",v offset,h offset)
defineSubmenuProperties(180,"left","left",0,0);

// add submenu link items ("url","Link name","_target","alt text")

// define child menu properties (width,"align to edge","text-alignment",v offset,h offset)
defineChildmenuProperties(170,"left","center",-3,-30);

// add child menu link items ("url","Link name","_target","alt text")

addMainItem("","Articles & Tips",103,"center","","",0,0);

defineSubmenuProperties(335,"left","left",0,0);

addSubmenuItem("info.html" ,"Articles Home","_self","");
addSubmenuItem("pages.html","From the Pages of Our Newsletter","_self","");
addSubmenuItem("ebooks.html","Free eBooks","_self","");

jatar_k

5:34 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



i think that the developer was saying that you could do this

instead of
addMainItem("index.html","Home",115,"center","","",0,0);

put
addMainItem("index.html?exit=false","Home",115,"center","","",0,0);

i don't know if this fixes the problem but that is what he meant it seems, you just add ?exit=false to the end of each link in each item.

jon5858

6:06 pm on Apr 24, 2002 (gmt 0)



Thanks Jatar. It's still calling the popup, so I guess I'll try getting in touch with the developer and see if he has any other ideas.

All the best,
Jon

jatar_k

6:18 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



can you post the popup function and we can see how it works.

jon5858

6:31 pm on Apr 24, 2002 (gmt 0)



Sure thing:

The script is:

<script>

<!-- This Script Is Copyright © 2001 The -->
<!-- Effective Marketing Group - All Rights -->
<!-- Reserved. If you use this code, you -->
<!-- MUST include this copyright header. -->

function getCookie(NameOfCookie)
{
if (document.cookie.length > 0)
{
begin = document.cookie.indexOf(NameOfCookie+"=");
if (begin != -1)
{
begin += NameOfCookie.length+1;
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end));
}
}
return null;

}
function setCookie(NameOfCookie, value, expiredays)
{
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays*24*60*60*1000));

document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}
var exit=true;
function leave()
{
visited=getCookie('visited');
if (exit)
if (visited==null)
{
setCookie('visited','yes',1) // SET AMOUNT OF DAYS HERE
window.open('xpop.html','popup','location=no,toolbar=no,resizable=yes,scrollbars=yes,width=400,height=550');
}
}
</script>

And this is included in the <BODY> tag:

<BODY onUnload="leave()">

jatar_k

6:42 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



can you sticky me the url and I can then get a better sense of how this is all working.

jon5858

6:48 pm on Apr 24, 2002 (gmt 0)



Jatar,

I have it set up on 404 error page -

<snip>

(edited by: Xoc at 8:37 pm (utc) on April 24, 2002)

jatar_k

8:33 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



one definite problem is no semicolon following the function call in the body tag.
you say it pops up all the time?
I can't get it to popup at all.

<added>you can put that url in your profile if you want people to check it out.

jatar_k

9:21 pm on Apr 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



function leave()
{
visited=getCookie('visited');
if (exit)
if (visited==null)
{
setCookie('visited','yes',1) // SET AMOUNT OF DAYS HERE
window.open ('xpop.html','popup','location=no,toolbar=no,resizable=yes,scrollbars=yes,width=400,height=550');
}
}

this statement has problems as well, you have if (exit) but the braces would seem to be missing I would think it should be like this

function leave()
{
visited=getCookie('visited');
if (exit) {
if (visited==null)
{
setCookie('visited','yes',1) // SET AMOUNT OF DAYS HERE
window.open ('xpop.html','popup','location=no,toolbar=no,resizable=yes,scrollbars=yes,width=400,height=550');
}
}
}
then it would check if exited is true then set the cookie and show the popup