Link to home
Start Free TrialLog in
Avatar of cmaorg
cmaorg

asked on

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>
Avatar of mrichmon
mrichmon

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
Avatar of cmaorg

ASKER

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
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?
Avatar of cmaorg

ASKER

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!!!
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.
Avatar of cmaorg

ASKER

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
Can you explain the purpose of the popup - it is very difficult to help without understanding what you are trying to do.
Avatar of cmaorg

ASKER

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
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?
Avatar of cmaorg

ASKER

The complete code is in my initial request.
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.
Avatar of cmaorg

ASKER

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?
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.
Avatar of cmaorg

ASKER

So what should I do? If I remove that line will it work with the popup javascript and still send the referring URL?
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
Avatar of cmaorg

ASKER

How do I do that?
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.
Avatar of cmaorg

ASKER

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
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?
Avatar of cmaorg

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cmaorg

ASKER

Perfect...I will try that today.
Avatar of cmaorg

ASKER

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
Avatar of cmaorg

ASKER

It's me again...when I use the javascript pop up...the link of the page does not show in the e-mail. HELP!!!
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
Avatar of cmaorg

ASKER

You are the best! It works perfectly now!!!

Thanks so much again.

cmaorg
Avatar of cmaorg

ASKER

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???
>>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")>
Avatar of cmaorg

ASKER

That worked perfectly!!! Thanks a billion.