Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Send a friend a page url

Posted on 2005-05-11
29
Medium Priority
?
503 Views
Last Modified: 2013-12-24
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>
0
Comment
Question by:cmaorg
  • 16
  • 13
29 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 13988577
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
 

Author Comment

by:cmaorg
ID: 14001125
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 14003886
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
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Author Comment

by:cmaorg
ID: 14004184
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 14011067
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
 

Author Comment

by:cmaorg
ID: 14011739
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 14011801
Can you explain the purpose of the popup - it is very difficult to help without understanding what you are trying to do.
0
 

Author Comment

by:cmaorg
ID: 14045521
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 14046560
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
 

Author Comment

by:cmaorg
ID: 14046636
The complete code is in my initial request.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 14046731
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
 

Author Comment

by:cmaorg
ID: 14047033
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 14048940
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
 

Author Comment

by:cmaorg
ID: 14052037
So what should I do? If I remove that line will it work with the popup javascript and still send the referring URL?
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 14060849
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
 

Author Comment

by:cmaorg
ID: 14062513
How do I do that?
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 14062751
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
 

Author Comment

by:cmaorg
ID: 14062901
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 14063496
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
 

Author Comment

by:cmaorg
ID: 14076772
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
 
LVL 35

Accepted Solution

by:
mrichmon earned 2000 total points
ID: 14078277
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
 

Author Comment

by:cmaorg
ID: 14078495
Perfect...I will try that today.
0
 

Author Comment

by:cmaorg
ID: 14082654
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
 

Author Comment

by:cmaorg
ID: 14082681
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 14086966
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
 

Author Comment

by:cmaorg
ID: 14090110
You are the best! It works perfectly now!!!

Thanks so much again.

cmaorg
0
 

Author Comment

by:cmaorg
ID: 14090394
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 14090671
>>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
 

Author Comment

by:cmaorg
ID: 14090747
That worked perfectly!!! Thanks a billion.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question