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
01
<!--?<span
class
=
"hiddenSpellError"
pre=
""
data-mce-bogus=
"1"
-->php
03
$random_id
= 125845465;
09
12px;font-weight:bold;
" href="
http:
11
Build a website quickly
and
easily
12
Customizable templates
and
graphics
17
12px;font-weight:bold;
" href="
http:
19
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.
23
12px;font-weight:bold;
" href="
http:
25
With every domain you register with <a href=
"http://www.purabtech.in/files/"
rel=
"nofollow"
>wordpressapi</a> you get FREE hosting.
29
$HTML
= "
var
objHead = document.getElementsByTagName(
'head'
);
30
var
objCSS = objHead[0].appendChild(document.createElement(
'link'
));
31
objCSS.id =
'.$random_id.'
;
32
objCSS.rel =
'stylesheet'
;
33
objCSS.href =
'http://YOURSITE/STYLE.css'
;
34
objCSS.type =
'text/css'
;";
37
var
WORDPRESAPI_html_
'.$random_id.'
= document.createElement(
"div"
);
38
WORDPRESAPI_html_
'.$random_id.'
.id =
"WORDPRESAPI_html_'.$random_id.'"
;
39
WORDPRESAPI_html_
'.$random_id.'
.style.position =
"absolute"
;
40
WORDPRESAPI_html_
'.$random_id.'
.style.zIndex =
"100"
;
41
WORDPRESAPI_html_
'.$random_id.'
.style.left =
"0px"
;
42
WORDPRESAPI_html_
'.$random_id.'
.style.top =
"0px"
;
43
WORDPRESAPI_html_
'.$random_id.'
.style.visibility =
"hidden"
;
44
WORDPRESAPI_html_
'.$random_id.'
.style.filter =
"progid:DXImageTransform.Microsoft.Alpha(opacity=100)"
;
45
WORDPRESAPI_html_
'.$random_id.'
.innerHTML =
"'.addcslashes($DYNAMIC_HTML,"
\\\'\
"&\n\r<>"
).'";
46
document.body.appendChild(WORDPRESAPI_html_
'.$random_id.'
);';
In this code if you observe then following line is very important.
1
WORDPRESAPI_html_
'.$uniqid.'
.innerHTML =
"'.addcslashes($HTML,"
\\\'\
"&\n\r<>"
).'";
How to append html code using javascript and php
Whenever you are using javascript and PHP both together then use following way to push your HTML in Dom.