How to append the html code using javascript and php

Sponsors

In this example I am going to show you how to add the dynamic HTML code into Document using javascript and PHP

<?php

$random_id = 125845465; // PUTTING SOME RANDOM ID YOU CAN USE YOURSELF.

$DYNAMIC_HTML = '<div>
<b>Sponsored Links</b>

<div>
 <span><a style="font-size:12px;font-weight:bold;" href="http://www.ucoz.com/" rel="nofollow">Create a website for free - uCoz</a></span><br />
Build a website quickly and easily
Customizable templates and graphics

</div>

<div>
 <span><a style="font-size:12px;font-weight:bold;" href="http://www.wordpressapi.com/files/domain_names/">$1.99 Domain Names</a></span><br />
 With every new non-domain purchase thru <a href="http://www.wordpressapi.com/files/domain_names/" rel="nofollow">wordpressapi</a>, you get a domain name for only $1.99.
</div>

<div>
 <span><a style="font-size:12px;font-weight:bold;" href="http://www.wordpressapi.com/files/" rel="nofollow">FREE Hosting!</a></span><br />
 With every domain you register with <a href="http://www.wordpressapi.com/files/" rel="nofollow">wordpressapi</a> you get FREE hosting.
</div>
</div>';

 $HTML = "var objHead = document.getElementsByTagName('head');
 var objCSS = objHead[0].appendChild(document.createElement('link'));
 objCSS.id = '.$random_id.';
 objCSS.rel = 'stylesheet';
 objCSS.href = 'http://YOURSITE/STYLE.css';
 objCSS.type = 'text/css';";

 $HTML .= '
 var WORDPRESAPI_html_'.$random_id.' = document.createElement("div");
 WORDPRESAPI_html_'.$random_id.'.id = "WORDPRESAPI_html_'.$random_id.'";
 WORDPRESAPI_html_'.$random_id.'.style.position = "absolute";
 WORDPRESAPI_html_'.$random_id.'.style.zIndex = "100";
 WORDPRESAPI_html_'.$random_id.'.style.left = "0px";
 WORDPRESAPI_html_'.$random_id.'.style.top = "0px";
 WORDPRESAPI_html_'.$random_id.'.style.visibility = "hidden";
 WORDPRESAPI_html_'.$random_id.'.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
 WORDPRESAPI_html_'.$random_id.'.innerHTML = "'.addcslashes($DYNAMIC_HTML,"\\\'\"&\n\r<>").'";
 document.body.appendChild(WORDPRESAPI_html_'.$random_id.');';

echo $HTML;

?>

In this code if you observe then following line is very important.

 WORDPRESAPI_html_'.$uniqid.'.innerHTML = "'.addcslashes($HTML,"\\\'\"&\n\r<>").'"; 

php

Whenever you are using javascript and PHP both together then use following way to push your HTML in Dom.

Incoming search terms:

You may like following Articles!

12 thoughts on “How to append the html code using javascript and php

  1. I think this write up was probably a good kick off to a potential series of write ups about this topic. A lot of writers act like they comprehend what they’re writing about when it comes to this topic and most of the time, very few people actually get it. You seem to understand it though, so I think you should run with it. Thanks a lot!

  2. Wow, this can be a good weblog you’ve obtained the following. Your post was actually helpful and educational, i can not wait to learn some much more. I started playing Farmville about three months a go and i cant believe how addictive it is :) . I didn’t realise there was so considerably to understand about it either lol. I’ve invested ages looking for good tips and stuff and this can be good. I found an additional actually great website at Farmville Hintsthats has genuinely good points and cheats as well. Btw, if any person else has any good ideas then i wouldn’t thoughts hearing them also. Thanks a great deal for this.

  3. Thank you for such a fantastic blog. Where else could one get this kind of info written in such an incite full way? I have a presentation that I am just now working on, and I have been looking for such information.

  4. I rarely leave comments in blogs, mostly because I don’t feel the urge to do so. On the few occasions when I do feel the urge, I give up if there’s any kind of registration process involved. It’s just not worth the hassle. I did make an exception to post this comment, though, so I guess it’s not a hard and fast rule.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>