Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9226981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:57:29+00:00 2026-06-18T04:57:29+00:00

Im creating a custom bbcode for phpbb, in which i need a select all

  • 0

Im creating a custom bbcode for phpbb, in which i need a “select all” and a “expand/collapse” function. The expand/collapse option should then have a specific style when scrolling is active.

The select and expand/collapse work fine, but where i have a problem is when looking for if scrolling is active.

First the scrolling and looking for it works fine, but the bbcode is not unique (only works on the first one posted)
Second the getElementByTagName(‘testlink’) for the expand/collapse link does not work.

So quickly excplayn what i want the script to do, and what is working so far.

  • When div class is ready run function – working
  • set var for the link class (testlink) – not working
  • set var for the content div class – working
  • set var for scrolling – working
  • try to scroll content – working
  • if scrolling works scroll back up – working
  • if scrolling works set visibility of (testlink) to visible – not working
  • if no scrolling (else) set visibility of (testlink) to hidden – not working

Javascript:

$(document.getElementsByTagName('pre_header')[0]).ready(
    function () {
    var expandlink = this.getElementsByTagName('testlink')[0];  
    var eee = this.getElementsByTagName('dd')[0];   
    var old = eee.scrollTop;
    eee.scrollTop += 220;


    if (eee.scrollTop > old) {
        eee.scrollTop -= 220;
        expandlink.style.visibility = "visible";
    } 
    else {
        expandlink.style.visibility = "hidden";
        };  
    }
);

HTML:

<div class="pre">
    <dt class="pre_header">
        <b>Code: </b>
        <a class="testlink" href="#">expand</a>
    </dt>
    <dd style="overflow:auto;">
        content here
    </dd>
</div>

Hope to get some help, and when it all done ill add the whole BBcode for others to use..

/megaman

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:57:30+00:00Added an answer on June 18, 2026 at 4:57 am

    Well i got i to work by myself so as promised here my working code. Hope this will help others. and feel free to usage it on your own phpbb forums.

    /megaman

    ps. the expand/collapse button i have disabled for IE because issues with scrollTop.

    BBCode usage:

    [pre]{TEXT}[/pre]
    

    HTML replacement

    <script type="text/javascript">
    // select all function
    function selectCode(a)
    {
        // Get ID of code block
        var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
        // Not IE and IE9+
        if (window.getSelection)
        {
            var s = window.getSelection();
            // Safari
            if (s.setBaseAndExtent)
            {
                s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
            }
            // Firefox and Opera
            else
            {
                // workaround for bug # 42885
                if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
                {
                    e.innerHTML = e.innerHTML + '&nbsp;';
                }
    
                var r = document.createRange();
                r.selectNodeContents(e);
                s.removeAllRanges();
                s.addRange(r);
            }
        }
        // Some older browsers
        else if (document.getSelection)
        {
            var s = document.getSelection();
            var r = document.createRange();
            r.selectNodeContents(e);
            s.removeAllRanges();
            s.addRange(r);
        }
        // IE
        else if (document.selection)
        {
            var r = document.body.createTextRange();
            r.moveToElementText(e);
            r.select();
        }
    }
    
    //expand - collapse settings
    function expandcollapse(a) {
        var ee = a.parentNode.parentNode.getElementsByTagName('dd')[0];
        if (ee.style.maxHeight == '200px') 
            { 
            ee.style.maxHeight = '2000px'; 
            a.innerHTML = 'collapse';
            } 
            else { 
                ee.style.maxHeight = '200px';
                a.innerHTML = 'expand';
                };
    }
    
    </script>
    <![if !IE]>
    <script type="text/javascript">
        function scrolltest(k) {
            var eee = k.getElementsByTagName('dd')[0];
            var old = eee.scrollTop;
            eee.scrollTop += 1;
    
            if (eee.scrollTop > old) {
                eee.scrollTop -= 1;
                k.getElementsByTagName('a')[1].style.visibility = "visible";
            } 
        }
    </script>
    <![endif]>
    
    <div class="pre" onmouseover="scrolltest(this); return false;">
        <dt class="pre_header">
            <b>Code: </b>
            <a href="#" onclick="selectCode(this); return false;">Select all</a>
            <a style="float:right; visibility:hidden;" href="#" onclick="expandcollapse(this); return false;">expand</a>
        </dt>
        <dd style="max-height:200px; overflow:auto;">
            <code>
                {TEXT}
            </code>
        </dd>
    </div>
    

    Help line

    Code: [pre]Add content here[/pre]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have mastered creating custom data types and adding fields with CCK. Then I
while creating custom item renderers which interfaces we need to implement? Thank in advance.
I'm creating custom forum software for a site I'm building, which includes 2 tables
Jython is great for creating custom data structures on need basis, but how to
I am creating custom membership provider for my asp.net application. I have also created
I'm creating custom control and because I need to do lot's of binding inside
I'm having some trouble creating custom routes for my blog module (which I'm doing
I'm having a problem creating custom report. Is there an option to filters to
I have just followed a tutorial about creating custom WordPress theme, each and everything
I'm learning about creating custom routes in ASP.NET MVC and have hit a brick

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.