Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  67] [ 2]  / answers: 1 / hits: 17765  / 13 Years ago, sun, october 2, 2011, 12:00:00

How can I align the entire script to center? I've never actually coded before in javascript and I just want to modify a quick bookmarklet. I've tried stuff like align=center for different components of the script but no luck. Is there something like <center> (in html) for js?



Thanks



EDIT: basically i want this to be centered on a page



function dEmbed(){
var iframe = document.createElement(iframe);
iframe.src = 'http://www.google.com';
iframe.style.width = w+'px';
iframe.style.height= h+'px';
iframe.style.border= 0;
iframe.style.margin= 0;
iframe.setAttribute(scrolling,no);
iframe.setAttribute(id,NAME);
document.body.insertBefore(iframe, document.body.firstChild);
}

More From » center

 Answers
13

I was able to achieve this by injecting the iframe into an existing div with text-align: center.



Here is the example: http://jsfiddle.net/MarkKramer/PYX5s/4/


[#89832] Thursday, September 29, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brendan

Total Points: 426
Total Questions: 110
Total Answers: 94

Location: Western Sahara
Member since Mon, May 3, 2021
3 Years ago
;