I'm in need of a way to se开发者_如何学JAVArve either HTML or links to external webpages. Basically what needs to be done is we will have webpages, and then would like to give a user of our site a URL or piece of javascript to insert into their own page, which will then display our HTML on their page upon load.
Can somebody please guide me in the right direction?
Thanks!
What you appear to need is the iframe tag.
You could use javascript to pull the content from your site
<script src="http://youdomain.com/mycontent.js">
</script>
then in your js file use
var myhtml ='';
myhtml += "Put your html in here";
document.write(myhtml);
<?php
// JsAdServer.php Copyright(c) 2013 by Phillip S. Smith Enterprises
// ok to use but include my copyright notice in code.
$htmlcontent=file_get_contents($url);
// you may also use curl or any other method to populate $htmlcontent
$jsContent=$htmlcontent;
$jsContent=preg_replace('/>\s+</','><',$jsContent);
$jsContent=str_replace("<hr />",'',$jsContent);// remove if hr's required
$jsContent=str_replace(chr(13),'',$jsContent);
$jsContent=str_replace(chr(10),'',$jsContent);
$jsContent=str_replace("'","\'",$jsContent);
$jsContent=str_replace('a href="','a target="new" rel="nofollow" href="',$jsContent);
print "document.write('$jsContent');";
?>
精彩评论