0

I m trying to give style to an iframe but it not work

document.getElementsByTagName("iframe").style.resize ="vertical";

I have to give this style to this iframe tag. But when i try this code it gives me error like:

property 'resize' of undefined
    at editPart (c2fd0a58-2ee5-4f88-a11d-c99edf724bbe:443)
    at HTMLTableCellElement.onclick (c2fd0a58-2ee5-4f88-a11d-c99edf724bbe:1)

this is javascript part:

function editPart(url) {

$("#windowEditPart").kendoWindow({
    content: {
        url: url
    }
});
var kendoWindowData = $('#windowEditPart').data('kendoWindow');
kendoWindowData.refresh();
kendoWindowData.center().open();

    window.createTimeout(() => {
         document.getElementsByClassName("k-content")[1].style.resize = "vertical";
    }, 0);
}

here s html part of iframe

<iframe title="Editable area. Press F10 for toolbar." frameborder="0" class="k-content" src='javascript:""'>

</iframe>
2
  • 1
    The problem isn't within setting resize to vertical, it's about document.getElementsByTageName failing to capture an element. Please share your HTML, so we can debug this problem. Commented Apr 7, 2018 at 14:59
  • Are you using Kendo? Commented Apr 7, 2018 at 19:20

1 Answer 1

1

getElementsByTagName returns a collection, so you have to select the first item in the returned array:

document.getElementsByTagName("iframe")[0].style.resize = "vertical";

If you know the class you could use

document.getElementsByClassName("k-content")[i].style.resize = "vertical";

where is the index of your iframe in the list of all elements with the class k-content

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.