Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
php email include javascript
Old 07-10-2006, 07:32 AM php email include javascript
Super Talker

Posts: 145
Trades: 0
Hello everyone,

I have created a web page where the user send an email to his friend with a message and a url of a website. I am using the mail function in order to send the email. I have creaed also a template for the email that the friend will receive.
I am using html code in order to create the email. In the template of the email I am using also a javascript as I want the friend to open the url in a pop up window. The problem is that the javascript doesn't work.Can I use javascript in the email template?Here is my code

PHP Code:
$body "<html>
<head>
<title>A wish send to you by 
$name</title>
<script type='text/javascript'>

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}



</script>
</head>
<body>
  <table width='752' border='0' align='center' cellpadding='0' cellspacing='0'>
    <tr>
      <td><img src=
$image></td>
    </tr>
    <tr>
      <td>This e-mail is from 
$sendername at $sendermail about a nice jewellery they've found. You can see it at the link <a href='#' onClick='popUpWindow('http://mysite.com/item_details_friend.php?itemID=$frienditem', '150', '100', '780', '560');'>$siteaddress</a> . This is the message $sendername sent. $message</td>
    </tr>
  </table>
</body>
</html>"
;

$thesubject "A nice jewellery from $sendername";
$headers "From: $sendermail\n";               // From
$headers.= "Content-Type: text/html; charset=iso-8859-1\n"// Mime type
$to="$receivermail";


mail($to,$thesubject,$body,$headers);

echo 
"Your e-mail was sent successfully.";

Thank you,
Xenia
xenia is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-10-2006, 10:54 PM Re: php email include javascript
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
No, JS will probably not work in most email clients. HTML email is a very tricky thing to get down. SitePoint has a good article on HTML emails: How to Code HTML Email Newsletters.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 07-11-2006, 04:22 AM Re: php email include javascript
Super Talker

Posts: 145
Trades: 0
Oh i see so there is no way that i can use javascript?
The problem is that i want to use javascript because i want the link that the custoemr will receive to open in a pop up window because the basic webiste is in a pop up window.

Do you know if there is any other solution?

Thanks,
Xenia
xenia is offline
Reply With Quote
View Public Profile
 
Old 07-11-2006, 02:01 PM Re: php email include javascript
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
There may be some clients that will run your JS, but the vast majority will not. I can only suggest making a new page on the site that is meant specifically for incoming visitors via Email, which then opens up the page. So link to mysite.com/emailusers.html and have that page open the popup.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 07-12-2006, 05:06 AM Re: php email include javascript
Super Talker

Posts: 145
Trades: 0
Thank you Chroder for your suggestion.

The problem i have is that the user will receive a url that his friend send including a specific itemId for a particular product,so the url will be like that:
http://mysite.com/item_details_friend.php?itemID=20 .

If the user click on this link I would like the page to open in a pop up window.

What I manage to do untill now is in the page http://mysite.com/item_details_friend.php?itemID=20 to put an action when the page loads to open the page in a pop up window.The problem I get is that the page ones in a pop up window however it always reloads the page.

Here is the code for the javescript i created:
Code:
<script language="JavaScript">
  function pop_window() {
  
    window.open('http://mysite.com/item_details_friend.php?itemID=20', 'popup', 'width=600, height=600, top=100, left=100, menubar=0, scrollbars=0, location=0, toolbar=0,  resizable=0, status=0');
    
  }
</script>
and in the body of the code:

HTML Code:
<body onLoad="pop_window();">
What you think?

thanks
xenia is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to php email include javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16422 seconds with 12 queries