I am trying to center an iframe by wrapping it in center tag using javascript i tried below script but its not working
<iframe id="xiframe" class="xiframe" src="https://www.w3schools.com" title="W3Schools Free Online Web Tutorials">
I used following script which is not working
function wrap(el, wrapper) {
        el.parentNode.insertBefore(wrapper, el);
        wrapper.appendChild(el);
    }
    
    // example: wrapping an anchor with class "wrap_me" into a new div element
    wrap(document.querySelector('xiframe'), document.createElement('center'));
I had tried css solution before that didn't work.
iframe {
  display:block;
  border: 3px dotted;
  width: 300px;
  height: 300px;
  align:center;
}
There are question raised on stackoverflow but those solution are not working. Only working solution so far is when i manually wrap iframe in center tag
<center><iframe id="xiframe" class="xiframe" src="https://www.w3schools.com" title="W3Schools Free Online Web Tutorials"></center>
i want to achieve same using JavaScript
