Generate javascript embed code for users - Stack Overflow

I have been trying to figure out how I can generate a piece of javascript code that will allow site use

I have been trying to figure out how I can generate a piece of javascript code that will allow site users to copy and paste it into their own sites, much like google Adsense and there embed code:

<– Begin Google Adsense code –>
<script type=”text/javascript”>
google_ad_client = “ad-client-code-goes-here”;
google_ad_slot = “ad-slot-code-goes-here”;
google_ad_width = 300;
google_ad_height = 250;
</script>
<script type=”text/javascript”
src=”.js”>
</script>
<– End Google Adsense code –>

I would love to create something like that.I am doing a similar service as a project and would like users to upload an image (advertisement) and then have them click a link 'generate ad code' and then they will receive a similar piece of code snippet like the one above in which they can paste into their website.

Any help on this would be great, Thank you.

I have been trying to figure out how I can generate a piece of javascript code that will allow site users to copy and paste it into their own sites, much like google Adsense and there embed code:

<– Begin Google Adsense code –>
<script type=”text/javascript”>
google_ad_client = “ad-client-code-goes-here”;
google_ad_slot = “ad-slot-code-goes-here”;
google_ad_width = 300;
google_ad_height = 250;
</script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication./pagead/show_ads.js”>
</script>
<– End Google Adsense code –>

I would love to create something like that.I am doing a similar service as a project and would like users to upload an image (advertisement) and then have them click a link 'generate ad code' and then they will receive a similar piece of code snippet like the one above in which they can paste into their website.

Any help on this would be great, Thank you.

Share Improve this question asked Aug 18, 2009 at 11:45 Spyderfusion02Spyderfusion02 1,0733 gold badges18 silver badges26 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

There are many ways to do this -

  • You can host the clickable ad image uploaded to the server in an IFrame. Basically you'll be giving the user the HTML code for an IFrame which will load the ad based on an advertisement id passed as a query string.

  • You can also use a simple image tag surrounded by an anchor tag acting as a link. The image will be loaded from a dynamic page based on the ad identifier.

Example 1

<iframe src="http://addomain./ad.aspx?id=123234234"></iframe>

Example 2

<a href="http://addomain./adstracker.aspx?id=1223094">
    <img src="http://addomain./imageserver.aspx?id=1223094" />
</a>

The first example will load the iframe with a URL containing the ad id. The ad.aspx page will dynamically generate the ad based on the id passed to it in the query string.

The second example will redirect the user to an ad tracker page, which will track that the ad has been clicked, and then based on the ad id, the user will be redirected. The imageserver.aspx page will serve the ad image.

I think I might be missing something... I'm assuming you're want to do this with Javascript? You would have your base code as a string in javascript (strScript in my example). Then you just replace the proper values, and throw it in a textbox?

var strScript = "<script>do_something_for_user(USER_ID);</script>" // Base script
strScript = strScript.replace(/USER_ID/, this_users_id)            // Replace the values
document.getElementById('someTextBox').value = strScript;            // Assign to textbox

That last line might be a tad off, but you'll be able to figure it out.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745604147a4635576.html

相关推荐

  • Generate javascript embed code for users - Stack Overflow

    I have been trying to figure out how I can generate a piece of javascript code that will allow site use

    18小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信