开发者

JavaScript display remote content

I'm building an affiliate system and in interested in knowing which would be the most reliable way to display remote banners. I mean for the affiliates to grab a piece of code and 开发者_Go百科use it to display banners, it whatever on their sites.

Doesnt have to be JavaScript and I'm using php


The two simplest ways I can think of are:

  1. To have the server side generate an image, like Mathias said, then the affiliate would need to add something like <img src="http://your.site.name/script.php">.

  2. Have the affiliate use an iframe, then you can return whatever HTML you need, and they need to add something like <iframe src="http://your.site.name/script.php"> to their pages.

Google ads, on the other hand, use javascript to generate that iframe, which gives them greater flexibility, at the cost of a more complex solution on their end.


I strongle suggest u to use ajax

Sample javascript ajax codes

<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
}
</script>
</head>
<body>

<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>

</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜