Reputation: 1
I'm sorry for the length of this question, but I want to make sure I give the facts.
I have a new ad server which does 99% of what I need. The one area it doesn't work so great in is in sending text ads. Here's the scenario. I need to send an email and this email needs some text ads in case the user has images turned off. Our email client (Lyris) uses httpget
to grab our dynamically generated page. Now here is where the problem lies. The new ad server uses JavaScript to grab the ads off of their server. They offer email compliant tags, but nothing for text ads. So I thought I would load the text ad using their standard javascript on a page. I would then pull that data into a variable based on an ID. Ex: span id="ad"
Here is the jQuery code:
var j = jQuery.noConflict();
j(document).ready(function () {
var ad = j('#jscript').html().replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,'');
j('#ad').html(ad)
});
Here is my script code to call my ad position and display on the screen:
<span id="jscript" style="display:none">
<script>
<!--
OAS_AD('Position1');
-->
</script>
</span>
So I'm grabbing the data based on my span id and then removing any reference to script tags. What I'm left with is just the text of the ad, which is perfect. I can dump that on the screen and it looks and works great when viewing through a browser. But because I'm doing all of this in jQuery when I send through Lyris it obviously ignores my javascript.
So how would I be able to output the results of var ad = j('#jscript').html().replace(/)<[^<])<\/script>/gi,'');
into something my email client won't ignore?
Upvotes: 0
Views: 119
Reputation: 78920
I'm not familiar with Lyris, but it's doubtful that it will execute the JavaScript on your page then send the resulting content as email. Rather, it probably just downloads your page, script tags and all, and emails it, perhaps doing simple processing like image attachments.
If you want to create a particular version of your page that is more compatible with email clients, you're going to have to ensure that any modifications to your HTML are performed server-side, not client-side.
Upvotes: 1