Create javascript embed code for users

I'm trying to figure out how I can generate a javascript code snippet that will allow website users to copy and paste them to their own sites, just like Google Adsense and inject the code there:

<– 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.com/pagead/show_ads.js">
</script>
<– End Google Adsense code –>

I would like to create something like this. I perform a similar service as a project, and I would like users to upload an image (advertisement), and then click on the link β€œgenerate an advertising code”, and then they will receive a similar code fragment similar to the one indicated above, in which they can embed on their website.

Any help on this would be great, thanks.

+3
source share
2

-

  • IFrame , . HTML IFrame, , .

  • , , . .

1

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

2

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

iframe URL-, . ad.aspx , .

, , , . imageserver.aspx .

+3

, , , - ... , Javascript? javascript (strScript ). ?

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

, .

+1

Source: https://habr.com/ru/post/1715411/


All Articles