Send a friend a page url

Hello, it's me again.

I now have the script working fine however when I use a javascript popup window the link no longer shows in the e-mail that is sent. If I simple put a target=_blank then it works fine however I can't specify the dimensions of the popup window. Can you help me??? Here's the code:

<cfif #parameterexists(form.da_action)#>

<cfmail to="#email#" from="#from_email#" subject="Check This Site out" type="HTML">
<center>
<body text="##131313" link="##ff0000" vlink="##ff0000" alink="##ff0000">
<table width="100%" border="0" cellspacing="5" cellpadding="8">
 <tr>
  <td bgcolor="##333333">
   <table width="100%" border="0" cellpadding="0" cellspacing="10" bgcolor="##FFFFFF">
    <tr>
     <td width="96%">
      <p><font style="font-family: Arial, Helvetica, sans-serif; font-size:13px; color:##131313;"><b>Hello,</b>
          <p>      
       <strong>#from_name#</strong> invites you to visit the following page on the <strong>Web site Name</strong> Web site:
        <p><a href="#Form.da_action#">#Form.da_action#</a></p>
     
     <p>
     <strong>#from_name#</strong> also sent you the following message:<p>
     
     <p>#message#</p>
     
          </td>
    </tr>
  </table>
 </td>
 </tr>
</table>
</body>
</center>
</cfmail>
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<table width="100%" border="0" cellspacing="5" cellpadding="8">
 <tr>
  <td bgcolor="#333333"><span style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color:#ffffff;font-weight:bold;">E-mail a Friend</span>
   <table width="100%" height="200" border="0" cellpadding="0" cellspacing="10" bgcolor="#FFFFFF">
    <tr>
     <td align="center"><span style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color:#131313;font-weight:bold;">Your Email Has Been Sent.. Thank You</span></td>
    </tr>
  </table>
  </td>
 </tr>
</table>
<cfelse>
<table width="100%" border="0" cellspacing="5" cellpadding="8">
<form method="post" action="">
 <tr>
  <td bgcolor="#333333"><span style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color:#ffffff;font-weight:bold;">E-mail a Friend</span>
   <table width="100%" border="0" cellpadding="0" cellspacing="10" bgcolor="#FFFFFF">
    <tr>
     <td><label for="from_name" style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color: #131313;font-weight:bold;">Your Name:</label>
       <br>
       <input type="Text" name="from_name"></td>
    </tr>
    <tr>
     <td><label for="from_email" style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color: #131313;font-weight:bold;">Your Email Address:</label>
       <br>
       <input type="Text" name="from_email"></td>
    </tr>
     <tr>
     <td><label for="email" style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color: #131313;font-weight:bold;">Friend's Email Address:</label>
          <cfoutput>
        <input type="hidden" name="da_action" value="#CGI.HTTP_REFERER#">
        </cfoutput>
       <br>
       <input type="Text" name="email"></td>
    </tr>
    <tr>
     <td width="96%"><label for="message" style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color: #131313;font-weight:bold;">Message:</label><br>
     <textarea name="message" rows="5"></textarea>
     </font></td>
    </tr>
    <tr>
     <td><input name="submit" type="image" src="../images/bt_submit.gif" alt="Submit" /></td>
    </tr>
  </table>
  </td>
 </tr>
 </form>
</table>
</cfif>
</body>
</html>
cmaorgAsked:
Who is Participating?
 
mrichmonConnect With a Mentor Commented:
okay now I understand.

You want the code to look like aboe with the addition of the link from the main page looking like:



<a href="javascript:window.open('emailfriend.cfm','title','height=100,width=200');">Click here to email this page to a friend</a>
0
 
mrichmonCommented:
where are you putting the _blank?

You may want to consider window.open which allows dimensions to be specified

window.open('display.html','title','height=100,width=200');

http://www.devguru.com/Technologies/ecmascript/quickref/win_open.html
0
 
cmaorgAuthor Commented:
I have tried using the Javascript popup however when I do the e-mail that is sent no longer sends the referring link. Here's the code that I am using:

<a href="tools/sendfriend.cfm" onclick="window.open('tools/sendfriend.cfm','popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">test</a>

Please help!!!

cmaorg
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
mrichmonCommented:
It is very strange that you have the link go to the page and it open in a pop-up onclick of the link.

Any reason to be doing this?
0
 
cmaorgAuthor Commented:
This is a pop up script that I found on the internet. No matter which pop up script I use it doesn't retain the referrer address when the window opens...thus the URL is not being sent when the e-mail is sent. If I use a regular link with a target=_blank then the script works no problem however I am unable to size the window how I would like it to be sized. What am I doing wrong and why isn't the URL being passed to the form.da_action when I use a popup script?

Help!!!
0
 
mrichmonCommented:
Again why are you opening the page in a separate window and the current window?

The code doesn't make sense to be doing it that way.
0
 
cmaorgAuthor Commented:
How should I be doing it then? I want to use a popup that will retain the referrer address when the link is clicked.

Thanks
0
 
mrichmonCommented:
Can you explain the purpose of the popup - it is very difficult to help without understanding what you are trying to do.
0
 
cmaorgAuthor Commented:
I have the script that e-mails the URL of a page to a friend. It is working fine however when I use a javascript popup window the referring URL no longer shows in the e-mail that is sent. If I simple put a target=_blank then it works fine however I can't specify the dimensions of the popup window. I would like to use a pop up window...what am I doing wrong? I have included the code in my first help message.

Thanks
0
 
mrichmonCommented:
Okay I still am having trouble understanding.

Maybe the problem is that I don't understand what you mean by:

 I have tried using the Javascript popup however when I do the e-mail that is sent no longer sends the referring link

What is the referring link?  the page itself or the page it comes from?  Maybe you should send the link you want into the email page.

Can you show the mail code?
0
 
cmaorgAuthor Commented:
The complete code is in my initial request.
0
 
mrichmonCommented:
Well in that code you access form variables which means you post the form which means you CANNOT have it open in a pop-up via clicking a link as the form needs to post to get those variables.

I think you need to re-evaluate what you are doing.

Also I still do not see what you mean by referring link.
0
 
cmaorgAuthor Commented:
What is necessary for me get a user to be able to click a link, get a pop up window and have the link of the page that they were just on sent to a friend? A referring link is the initial page that the user was on when they clicked the link to e-mail the page to a friend.

Why is it that the form works fine when I use a link and a "target=_blank" then?
0
 
mrichmonCommented:
The reason the email is not sending is this line:
<cfif #parameterexists(form.da_action)#>

form.da_action does not exist since you are clicking a link, but looking at a form variable.

It works otherwise because you have a submit button which submits the form so the variable (parameter) is present and so the message sends.
0
 
cmaorgAuthor Commented:
So what should I do? If I remove that line will it work with the popup javascript and still send the referring URL?
0
 
mrichmonCommented:
Nope.

You need to reevaluate the logic of how you are doing this.

If you want to do it in a pop-up then you need to send the URL that you want to "send to a friend" to the pop-up via some other method.

Like a URL variable
0
 
cmaorgAuthor Commented:
How do I do that?
0
 
mrichmonCommented:
It involves chaning the form from POST to GET , then include the URL prefix instead of FORM, then send the URL variable into the pop-up window.


The best method is really as I mentioned to reevaluate your whole logic.  You probably don't want this whole thing as the same page since you want part in the browser and part in the pop-up.
0
 
cmaorgAuthor Commented:
I am new to Coldfusion...therefore can you point me somewhere where I can learn how to do this? Could you possibly send provide me with the code that would need changing?

Thanks so much
0
 
mrichmonCommented:
I would rewrite to something like the following.  What happens is the user fills out the form.  The email is sent and a confirmation displayed.

emailfriend.cfm
---------------------
<html>
<body>
<div style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color:#ffffff;font-weight:bold;">E-mail a Friend</div>
<form method="post" action="processemail.cfm">

<p><label for="from_name" style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color: #131313;font-weight:bold;">Your Name:</label><br>
<input type="Text" name="from_name"></p>
       
<p><label for="from_email" style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color: #131313;font-weight:bold;">Your Email Address:</label><br>
<input type="Text" name="from_email"></p>

<p><label for="email" style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color: #131313;font-weight:bold;">Friend's Email Address:</label><br>
<input type="Text" name="email"></p>

<input type="hidden" name="da_action" value=" <cfoutput>#CGI.HTTP_REFERER#</cfoutput>">

<p><label for="message" style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color: #131313;font-weight:bold;">Message:</label><br>
<textarea name="message" rows="5"></textarea></p>

<input name="submit" type="submit" value="Submit">

</form>
</body>
</html>

processemail.cfm
----------------------------
<cfif IsDefined("Form.Submit")>

<cfmail to="#email#" from="#from_email#" subject="Check This Site out" type="HTML">
<center>
<body text="##131313" link="##ff0000" vlink="##ff0000" alink="##ff0000">
<table width="100%" border="0" cellspacing="5" cellpadding="8">
 <tr>
  <td bgcolor="##333333">
   <table width="100%" border="0" cellpadding="0" cellspacing="10" bgcolor="##FFFFFF">
    <tr>
     <td width="96%">
      <p><font style="font-family: Arial, Helvetica, sans-serif; font-size:13px; color:##131313;"><b>Hello,</b>
          <p>      
       <strong>#from_name#</strong> invites you to visit the following page on the <strong>Web site Name</strong> Web site:
        <p><a href="#Form.da_action#">#Form.da_action#</a></p>
     
     <p>
     <strong>#from_name#</strong> also sent you the following message:<p>
     
     <p>#message#</p>
     
          </td>
    </tr>
  </table>
 </td>
 </tr>
</table>
</body>
</center>
</cfmail>
<cfelse>
<cflocation url="emailfriend.cfm">
</cfif>

<html>
<body>
<span style="font-family: Arial, Helvetica, sans-serif;font-size:11px;color:#131313;font-weight:bold;">Your Email Has Been Sent.. Thank You</span>
</body>
</html>


As for showing up in a pop-up I still don't understand the purpose - what is on the actual page the pop-up is called from then?
0
 
cmaorgAuthor Commented:
Thanks mrichmon, I will try your code today.

As for the reason for the pop up. I am sure that you have been to a Web site that has a link to a e-mail a friend from a page that contains an article let's say, that opens up in a pop up window. You fill out the form with your friend's e-mail address and the e-mail is sent with the article's name and URL. I would like to do this as well rather than have the code on every page of my site. This is the reason for the pop up.
0
 
cmaorgAuthor Commented:
Perfect...I will try that today.
0
 
cmaorgAuthor Commented:
Thank you, thank you, thank you!!! You have been a huge help! Thanks so much...it worked perfectly. The window pops up just the way I want it to.

cmaorg
0
 
cmaorgAuthor Commented:
It's me again...when I use the javascript pop up...the link of the page does not show in the e-mail. HELP!!!
0
 
mrichmonCommented:
I think the biggest problem is that you are using CGI.HTTP_REFERER

which does not always have a value.

You could do something like this:

<a href="javascript:window.open('emailfriend.cfm?sendtofriendurl=#CGI.SCRIPT_NAME#','title','height=100,width=200');">Click here to email this page to a friend</a>

ANd then accesss #URL.sendtofriendurl#

so that you use something besides HTTP_REFERER.

CGI.HTTP_REFERER jsut doesn't work consistently
0
 
cmaorgAuthor Commented:
You are the best! It works perfectly now!!!

Thanks so much again.

cmaorg
0
 
cmaorgAuthor Commented:
One last question...when I use a graphic submit button instead of the reguler submit button I get an error. However when I replace the coded button the script works fine. Does it have to do with this code at the beginning of the processemail.cfm page "<cfif IsDefined("Form.Submit")>"? How do I change it so that it will allow me to use an image as a submit button???
0
 
mrichmonCommented:
>>Does it have to do with this code at the beginning of the processemail.cfm page "<cfif IsDefined("Form.Submit")>"?
Yes it does.

>> How do I change it so that it will allow me to use an image as a submit button???

You have to check for something that indicates the form was submitted.  If you always have the <input type="Text" name="email"> defined then try
<cfif IsDefined("Form.Email")>
0
 
cmaorgAuthor Commented:
That worked perfectly!!! Thanks a billion.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.