Add a div to the dom?

For developers using the Construct 2 Javascript SDK

Post » Fri Jul 04, 2014 8:10 pm

Please help,

I've been trying to dynamically create a div to add to my program. What I have doesn't work. Could someone help me figure out what I'm doing wrong in my runtime. Here is the action:

Acts.prototype.Like_Button = function (l_verb, l_color, l_under, l_layout,l_faces,l_url,l_code)
{
var div1 = document.createElement("div");
div1.style.position="absolute";
div1.style.left="100px";
div1.style.top = "10px";
//div1.style.color = "white";
div1.innerHTML = '<div class="fb-like" data-href="http://lancelocke.yourhosting.com/fb/" data-layout="box_count" data-action="recommend" data-show-faces="true" data-share="true" data-ref="home_rec"></div>';
document.body.appendChild (div1);
};

Any help would be greatly appreciated.
www.h1k3.tech

We are here for you!
B
92
S
24
G
16
Posts: 716
Reputation: 17,082

Post » Sat Jul 05, 2014 7:49 am

That code looks like it ought to work, but that "fb-like" inner div looks like it will do nothing by itself unless you also include the script that makes it do something. TBH this isn't much specific to Construct 2, it's just ordinary JS code, so maybe you could ask somewhere like stackoverflow.com.
Scirra Founder
B
405
S
239
G
91
Posts: 24,763
Reputation: 197,330


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 2 guests