Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CFMAIL to email a page 2

Status
Not open for further replies.

ahksar

Programmer
Jan 11, 2001
43
US
I am a new user and I have to write code to email any web page to someone else. I am using CFMAIL to do that, but I am not able to get the URL of the page from the location bar, do I write a JavaScript function to do that, so I can just email the link? Also, if there are frames, the correct URL is not visible in the location bar, any ideas on how to overcome that?
Thanks
ahksar
 
Here's some code that should do what you want. It will call a script &quot;sendMail.cfm&quot; and pass two variables, &quot;url&quot; and &quot;to&quot;. &quot;Url&quot; should contain the page location even if it's in a frame and &quot;To&quot; will contain the e-mail address to send the mail to. You can then just the <cfmail> tag to generate your e-mail.

Let me know if you have trouble with it.
GJ

<form action=&quot;sendmail.cfm&quot; method=&quot;post&quot;>

<input type=&quot;submit&quot; value=&quot;Send this link to a friend&quot;>

E-mail address: <input type=&quot;text&quot; name=&quot;to&quot;>

<script>document.write(&quot;<input type=\&quot;hidden\&quot; name=\&quot;url\&quot; value=\&quot;&quot; + document.location.href + &quot;\&quot;>&quot;);</script>

</form>
 
To do it with only CF, do the following:

<cfoutput>#SERVER_NAME##SCRIPT_NAME#</cfoutput>

GunJack's approach is good to, but hey, since we have ColdFusion, let's use it :).

<webguru>iqof188</webguru>
 
Yea, I thought he was wanting to e-mail the url of the top page so I coded it with &quot;top.location.href&quot;. I re-read his question just before posting, realized he wanted the inner frame and changed &quot;top&quot; to &quot;document&quot;.

GJ
 
Thanks both of you for your replies and suggestions. They were helpful,and I implemented the javascript to get the URL from the frame.

ahksar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top