admin管理员组文章数量:1432594
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 badges2 Answers
Reset to default 3There 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.
本文标签: Generate javascript embed code for usersStack Overflow
版权声明:本文标题:Generate javascript embed code for users - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745604147a2665741.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论