简体   繁体   中英

Q: How can I create dynamically an iframe inside a web content using Python?

I am trying to create an iframe inside a web content (no matter where exactly need to be inserted). The only way that I need to do this, is just by making it dynamically and also by using Python3+ version. The iframe's information is not important either. Id, class name and more can be random or custom. It is not necessary to insert specific data. Also, I don't need an answer about the height and the width. I already have solved it.

What do I mean dynamically? I mean that if someone clicks on a button then I need to insert this iframe. If someone clicks on another button then I need to delete it, and so on.

Check my code below:

def function(given_from_user_url):
    """return the iframe result"""
    from IPython.display import IFrame
    return IFrame(url, width='50%', height=350) 

This function is returning an instance of an iframe with width equals with the 50% of the page and a height of 350 pixels. Then the result of this function you can use it was you want in your rest project. Is this what you are looking for?

Sounds like HTML / Javascript challenge. Why do you think it is related to python?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM