change the <iframe></iframe> with BBCode Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
2 posters

    change the <iframe></iframe> with BBCode

    erchima
    erchima
    Forumember


    Female Posts : 629
    Reputation : 15
    Language : INDONESIAN | Lua Script | Visual Basic | and Coding
    Location : Under your bed xD

    In progress change the <iframe></iframe> with BBCode

    Post by erchima May 21st 2014, 8:14 am

    how to make iframe with BBCode?
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13246
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: change the <iframe></iframe> with BBCode

    Post by Ange Tuteur May 21st 2014, 9:21 pm

    Hello erchima,

    You could probably write a small bit of javascript to convert your bbcode in posts to HTML.

    For example :

    Write
    Code:
    [iframe src="/myurl"][/iframe]

    This will just display as plain text since we have nothing to parse the bbcode server side.

    We can add a small script :
    Modules > javascript codes management > create a new script

    Title : your choice
    Placement : either in the topics or in all pages
    Paste the code below and submit :
    Code:
    $(function() {
        var frameHeight = 250;
        var frameWidth = 500;
        var d = document.getElementsByTagName('DIV');
        for (i = 0; i < d.length; i++) {
            if (d[i].className == 'postbody') {
                if (/\[iframe src="(.*?)"\]\[\/iframe\]/.test(d[i].innerHTML)) {
                    d[i].innerHTML = d[i].innerHTML.replace(/\[iframe src="(.*?)"\]\[\/iframe\]/ig,'<iframe src="$1" height="'+frameHeight+'" width="'+frameWidth+'"></iframe>');
                }
            }
        }
    });

    frameHeight and frameWidth are the dimensions of the iframe. Change these in the script to the size of your choice.
    erchima
    erchima
    Forumember


    Female Posts : 629
    Reputation : 15
    Language : INDONESIAN | Lua Script | Visual Basic | and Coding
    Location : Under your bed xD

    In progress Re: change the <iframe></iframe> with BBCode

    Post by erchima May 23rd 2014, 1:14 pm

    thank you very much  kiss  kiss  kiss