append html code using javascript and php, In this example I am going to show you how to add the dynamic HTML code into Document using javascript and PHP.
How to append html code using javascript and php
<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php $random_id = 125845465; // PUTTING SOME RANDOM ID YOU CAN USE YOURSELF. $DYNAMIC_HTML = '<div> <b>Sponsored Links</b> <div> 12px;font-weight:bold;" href="http://www.ucoz.com/" rel="nofollow">Create a website for free - uCoz Build a website quickly and easily Customizable templates and graphics </div> <div> 12px;font-weight:bold;" href="http://www.purabtech.in/files/domain_names/">$1.99 Domain Names With every new non-domain purchase thru <a href="http://www.purabtech.in/files/domain_names/" rel="nofollow">wordpressapi</a>, you get a domain name for only $1.99. </div> <div> 12px;font-weight:bold;" href="http://www.purabtech.in/files/" rel="nofollow">FREE Hosting! With every domain you register with <a href="http://www.purabtech.in/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<>").'";
Whenever you are using javascript and PHP both together then use following way to push your HTML in Dom.
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.
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.