|
Post by Wormopolis on Aug 2, 2009 0:13:16 GMT -8
Browser Tested: IE and FF placement: Global Header
Places a new menu button in your menubar that will open a quickform that allows you to send this site link to a friend. Uses your default email program. If you do not have a default email, this script will most likely not work.
code:
<script type="text/javascript"> <!-- // Invite a friend v2.1 // by Wormopolis - www.wormocodes.com // Keep header intact - do not repost
// User edit:
textMenusOn=false; //set to true if you use text menus
var inviteMessage= "Your friend wants you to check out this site:"; var inviteSubject= "Check out WormoCodes!"; var additionalMsgDefault="Its really cool!";
var inviteFriendBGColor = "000000"; var inviteFriendTextColor = "FFFFFF"; var inviteFriendBorderColor = "0000FF";
var inviteFriendClick="text"; //button or text var inviteBtnImage="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/InviteFriend.gif"; var inviteText="Invite Friend"; var inviteTextColor="0000FF";
// no need to edit (unless for styling) function updateStuff() { var temp="mailto:"; temp+=document.getElementById('feml').value; temp+="?subject="+inviteSubject; tmploc=location.href.split(/index/)[0]; tmpmsg=document.getElementById('sltf_msg').value tempnme=document.getElementById('fname').value; document.getElementById('sltf_msg').value="\nHey "+tempnme+"\n" +inviteMessage+ "\n\n"+tmploc+"\n\n"+tmpmsg; document.getElementById('sltf').action=temp; document.getElementById('feml').value=document.getElementById('fname').value=""; }
hold="<div id='wrmfrm' style='position: absolute; top: 100; left: 50; display: none; height:300; width:400; background-color: " +inviteFriendBGColor+ "; border-width: 2px; border-style: solid; border-color: " +inviteFriendBorderColor+ ";'><font color='" +inviteFriendTextColor+ "'><center><font size='3'>Send This Site Link to Friend</font></center><br><br>Friend's name: <input id='fname' style='width:230'> <br>Friend's email: <input id='feml' style='width:230'><br> <br><form onsubmit='document.getElementById(\"wrmfrm\").style.display =\"none\";' id='sltf' method='post' action= 'mailto:default@default.com' enctype='text/plain'>Additional message: <textarea id='sltf_msg' name='message' cols='30' rows='10'>" +additionalMsgDefault+ "</textarea><br><br><center><input onclick='updateStuff()' type='submit' value='Send'> <input onclick='document.getElementById(\"wrmfrm\").style.display =\"none\";' type='reset' value='Cancel'></center></form></font></div>"; document.write(hold);
hold2=(inviteFriendClick=="button" ? "<img border='0' src='" +inviteBtnImage+ "'" : "<font color='" +inviteTextColor+ "'"); hold2+=" onclick='document.getElementById(\"wrmfrm\").style.top =document.body.scrollTop + 100;document.getElementById(\"wrmfrm\").style.left=(document.body.scrollWidth/2 - 200); document.getElementById(\"wrmfrm\").style.display=\"\"; document.getElementById(\"sltf_msg\").value =additionalMsgDefault'"; hold2+=(inviteFriendClick=="button" ? " />" : ">" +inviteText+ "</font>");
if (textMenusOn) { for (lnks=document.getElementsByTagName('a'), n=0; n<lnks.length; n++) { if (lnks[n].href.match(/\/index\.cgi$/) && lnks[n].innerHTML=='Home') { menubar=lnks[n].parentNode.parentNode; nwbtn=lnks[n].cloneNode(true); nwbtn.href="javascript: void(0)"; nwbtn.innerHTML=hold2; menubar.appendChild(nwbtn); break; } } } else { for (img=document.images, i=0; i<img.length; i++) { if (img[i].alt=="[Home]") { menubar=img[i].parentNode.parentNode; nwbtn=img[i].parentNode.cloneNode(true); nwbtn.href="javascript: void(0)"; nwbtn.innerHTML=hold2; menubar.appendChild(nwbtn); break; } } }
// --> </script>
Preview: In my menubar
|
|
|
Post by DangerKart on Aug 2, 2009 1:56:21 GMT -8
Nice code Worm, i'd imagine alot of sites would like to have this feature. One question tho, does the envelope image use the image you have on site or is it customizable?
|
|
|
Post by Wormopolis on Aug 2, 2009 7:41:46 GMT -8
The image was hard-coded in the original script. Im about to make it a customizable variable however based off your suggestion.
|
|
blackball
Not New Member
Posts: 21
blackball said 0 great things
|
Post by blackball on Nov 10, 2009 23:08:48 GMT -8
Hello Wormo,
Great code!!!
I have a code by Eton, in my Global footer that seems to be conflicting with your invite code. It wont allow me to save any changes within my global headers, could you have a look at any changes that may be required, for both codes to work together.
The code in question is,
<script type="text/javascript"> <!-- /* Posting/PM Word Count - created by Eton Bones */
//set to minimum word count needed in order to make a post //or set to 0 to disable word count enforcement. var wordCountLimit=0;
if(document.getElementsByName('message').length){ var __submitBtn,__wc,__msg __msg=document.getElementsByName('message')[0]; __submitBtn=document.getElementsByTagName('input'); for(var count=0;count<__submitBtn.length;count++){ if(__submitBtn[count].accessKey && __submitBtn[count].accessKey=='s'){__submitBtn=__submitBtn[count];break;} } if(typeof(__submitBtn.length)=="undefined"){ __btnText=__submitBtn.value; __wc=document.createElement('div'); __wc.id="wordcount"; __wc.appendChild(document.createTextNode('Word Count: ')); __wc.appendChild(document.createElement('span')); __submitBtn.parentNode.appendChild(__wc); count=__msg.value.match(/\b\w+\b/g); count=(count)?count.length:0; __wc.lastChild.innerHTML=count; if(count<wordCountLimit && !location.href.match(/ion=pmsend/)){__submitBtn.disabled=true;} if(document.addEventListener){ __msg.addEventListener("keyup",wordUp,false); __msg.addEventListener("input",wordUp,false); __msg.addEventListener("change",wordUp,false); }else if(document.attachEvent){ __msg.attachEvent("onpropertychange",wordUp); }else{ __msg.onkeyup=wordUp; __msg.onmouseup=wordUp; __msg.onchange=wordUp; } } }
function wordUp(event){ if(this.document){var thiss=event.srcElement;}else{var thiss=this;} var count=thiss.value.match(/\b\w+\b/g); count=(count)?count.length:0; if(count>=wordCountLimit && wordCountLimit >0 && __submitBtn.disabled){ __submitBtn.disabled=false; } __wc.lastChild.innerHTML=count;
} //--> </script>
Thankyou in advance.
|
|
|
Post by Wormopolis on Nov 11, 2009 2:29:34 GMT -8
change this:
if(document.getElementsByName('message').length){
to this:
if(document.getElementsByName('message').length>1){
|
|
blackball
Not New Member
Posts: 21
blackball said 0 great things
|
Post by blackball on Nov 11, 2009 5:12:31 GMT -8
Thanks Wormo, Worked perfectly. :-)
|
|
Chez-Michael
Not New Member
(= Dream big =)[Sj1:0]
Posts: 13
Chez-Michael said 0 great things
|
Post by Chez-Michael on Apr 2, 2010 21:41:24 GMT -8
This is a sweet code but it's not working on our site presumably because we took out the menu bar. Is it possible to have it set to be underneath our featured topics module? Thanks a bunch =)
|
|
|
Post by Wormopolis on Apr 3, 2010 0:38:38 GMT -8
it can be changed to move somewhere else.. is the featured topics module something you wrote in HTML?
|
|
Chez-Michael
Not New Member
(= Dream big =)[Sj1:0]
Posts: 13
Chez-Michael said 0 great things
|
Post by Chez-Michael on Apr 3, 2010 21:27:35 GMT -8
I'm pretty sure its a Javascript code, it was made automatically after I uploaded the pics and links.
|
|
|
Post by Wormopolis on Apr 4, 2010 0:12:30 GMT -8
I guess I need to see the site then to see what elements are made. it can then be moved into one of them.
|
|
|
Post by Wormopolis on Apr 17, 2010 6:28:50 GMT -8
still never saw a link to the site you were referring to.
Im hesitant to move this into the database simply because it still doesnt work with email providers that are web based (like yahoo and hotmail). it works great if you have something like outlook that opens an actual dialog box.
apparently web based email providers disabled the ability to auto-populate things like subject and message because they were trying to prevent spam attacks. unless that changes, this code wont work to well for someone using their services.
|
|
Chez-Michael
Not New Member
(= Dream big =)[Sj1:0]
Posts: 13
Chez-Michael said 0 great things
|
Post by Chez-Michael on Apr 23, 2010 21:43:24 GMT -8
Been busy! I guess I won't use this then. Is a good idea tho =)
|
|
|
Post by Wormopolis on Apr 24, 2010 7:27:26 GMT -8
It will still TRY to make an email, but the message portion wont be auto-filled in like outlook gets.
|
|
daniel
Not New Member
Posts: 7
daniel said 0 great things
|
Post by daniel on May 29, 2010 15:38:24 GMT -8
this code is not working for some reason on my forum... It is my global headers right now, but is not showing up. dyin.proboards.com
|
|
|
Post by Wormopolis on May 29, 2010 19:23:12 GMT -8
Its because you had text menus on and the code didnt support text menus. I upgraded the version. there is a new variable at the top now you will need to change to true.
version upgrade 2.1: works with text menus now.
|
|