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 8251685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:19:07+00:00 2026-06-08T00:19:07+00:00

I have some custom elements in my HTML page. To do some modifications on

  • 0

I have some custom elements in my HTML page. To do some modifications on it, I wrote a JavaScript.

It has got some custom elements in it. These elements are added intentionally.

Sample Source:

<div>       
        <br />
     <a name="IDATLQHE"></a>
    <h2 class="subhead" xmlns="">
    <dev>
        <dd>
            <span>abcd</span>
        </dd>

        <rr>
            <span>
                    <a title="google" href="http://google.com">google.com</a>
            </span>
       </rr>                    
    </dev>
    </h2>       
</div>

Output needed:

I want to replace the contents of the <a> element in the <rr> element with the contents of the <dd> element. (The elements <rr>, <dd> and <dev> are the custom elements.)

JavaScript written:

<script type="text/javascript">
 var devs = document.getElementsByTagName('dev');
for(var i = 0, len = devs.length; i < len; i++)
{
    var dev = devs[i],
        h2 = dev.getElementsByTagName('rr'),
        h3 = dev.getElementsByTagName('dd');
    if(h2.length === 1)
    {
        var aa= h2[0],
        aaa=aa.getElementsByTagName('a');
        if(h2.length === 1 && h3.length === 1)
        {
            aaa[0].innerHTML = h3[0].innerHTML;
            h3[0].innerHTML=null;
        }
    }
}
</script>

This script is working fine in Firefox, but not in IE.

Edit:

After adding the HTML elements and adding different class attributes.

<div>       
            <br />
         <a name="IDATLQHE"></a>
        <h2 class="subhead" xmlns="">
         <div class="dummy">
             <div class="dummyy">
                <span>abcd</span>
            </div>

            <div class="dummyyy">
                <span>
                        <a title="google" href="http://google.com">google.com</a>
                </span>
          </div>                
        </div>
        </h2>       
    </div>

Modified Java Script:

  <script type="text/javascript">
    var divs = document.getElementsByClassName('dummy');
    for(var i = 0, len = divs.length; i < len; i++)
    {
        var div = divs[i],
        h2 = div.getElementsByClassName('dummyyy'),
        h3 = div.getElementsByClassName('dummyy');
        if(h2.length === 1)
        {
            var aa= h2[0],
            aaa=aa.getElementsByTagName('a');
            if(h2.length === 1 && h3.length === 1)
            {
                aaa[0].innerHTML = h3[0].innerHTML;
                h3[0].innerHTML=null;
            }
        }
    }

I am still facing the same problem. Its not working for IE(Version 8).

Can any one suggest the changes to be done to make it work in both IE and Firefox?

  • 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-08T00:19:09+00:00Added an answer on June 8, 2026 at 12:19 am

    While I played computer games at last evening I came up with idea that could solve you problem. When I tried it out by my self I’ve got the theory that non valid html tags won’t be created as an html object so you can’t access those with functions from the DOM. So I changed the custom tags -inclusive the dd tag though it is a valid html tag- into div tags and added a dummy css class as an identifier.
    The next change I made was to add the function getElementsByClass() method. Because document.getElementsByClassName() does not exists for IE8 and older, I rembered that I had found a function that does the same -note the differents in calling the function- there.
    The result of these changes is following:

       <script type="text/javascript">
        function test() 
        {
            var devs = getElementsByClass('dev');
            for(var i = 0, len = devs.length; i < len; i++)
            {
                var h2 = getElementsByClass('rr', devs[i]);
                var h3 = getElementsByClass('dd', devs[i]);
                if(h2.length === 1)
                {
                    aaa=h2[0].getElementsByTagName('a');
                    if(h2.length === 1 && h3.length === 1)
                    {
                        aaa[0].innerHTML = h3[0].innerHTML;
                        h3[0].innerHTML = "";
                    }
                }
            }
        }
    
        function getElementsByClass( searchClass, domNode, tagName) { 
            if (domNode == null) domNode = document;
            if (tagName == null) tagName = '*';
            var el = new Array();
            var tags = domNode.getElementsByTagName(tagName);
            var tcl = " "+searchClass+" ";
            for(i=0,j=0; i<tags.length; i++) { 
                var test = " " + tags[i].className + " ";
                if (test.indexOf(tcl) != -1) 
                    el[j++] = tags[i];
            } 
            return el;
        }
        </script>
    

    And it seems that does work…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom JSP tags that generate some HTML content, along with some javascript
I have sample HTML that I have marked up with some special tags that
I have some custom type: [RdfSerializable] public class Item { [RdfProperty(true)] public string Name
I have some custom logic that needs to be executed every single time a
I have a document type of info I also have some custom properites. infoTitle
I have some existing custom Excel workbooks/applications with code-behind C#, which work fine. They
I have authored some custom classes that I would like to create using XAML:
I am using the WordPress theme Studio8 and I have create some custom forms
I have a custom FrameLayout class which does some custom drawing on the OnSizeChanged
I have some regular alert views and a custom alert view called 'UINotificationAlertView' I

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.