Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    53
    Thanks
    17
    Thanked 1 Time in 1 Post

    Help with click() function

    I am trying to create a function that clicks a button within an iframe.

    I hope this is all that is needed....
    i figured something like this but i know i’m wrong cause it doesn’t work.

    function close_it(){
    var s = document.getElementById(“messagesBox”);
    var go = s.getElementByClassName(“box_title”);
    go.click();
    return false; }

    Here’s the Dom Tree.
    <div class="messagesBox" id="messagesBox" style="">
    <div style="" class="birdie clearfix">
    //The 401 is differant everytime.
    <div class="box_blue">
    <div class="box_top ">
    <a href="#" onclick="message.callNextInContainer($(this));return false"
    class="box_title" style"">X</a>

    Any help would be much appreciated.
    Last edited by cbiblis; 07-18-2011 at 12:50 AM.

  2. Users who have thanked cbiblis for this post:

    dhape (08-28-2011)

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    Where is the iframe in the DOM? You don't show it. Does it belong to the same domain, sub domain and protocol as the surrounding document?

  • #3
    New Coder
    Join Date
    Jan 2011
    Posts
    53
    Thanks
    17
    Thanked 1 Time in 1 Post
    Quote Originally Posted by devnull69 View Post
    Where is the iframe in the DOM? You don't show it. Does it belong to the same domain, sub domain and protocol as the surrounding document?
    Sorry, i'm not to good with this dom stuff. The function will call from the same domain. is this what your asking? if not what should i look for to find it?

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    You were talking about an iframe, but there is no iframe in your HTML code (at least you didn't show it).

  • #5
    New Coder
    Join Date
    Jan 2011
    Posts
    53
    Thanks
    17
    Thanked 1 Time in 1 Post
    Quote Originally Posted by devnull69 View Post
    You were talking about an iframe, but there is no iframe in your HTML code (at least you didn't show it).
    I must be wrong about it being an iframe then cause that is all it shows from the main doc element. Sorry for the confussion. i am learning. i assumed that it was an iframe because of the way it looks on the page. So if it's not an iframe could you show me the proper way to call it in a function?

  • #6
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    I am sure that this is not all your HTML code ... just because it is missing almost all the closing tags. Please show us the full code otherwise we will not be able to help you comprehensively.

  • #7
    New Coder
    Join Date
    Jan 2011
    Posts
    53
    Thanks
    17
    Thanked 1 Time in 1 Post
    Quote Originally Posted by devnull69 View Post
    I am sure that this is not all your HTML code ... just because it is missing almost all the closing tags. Please show us the full code otherwise we will not be able to help you comprehensively.
    the full page if really big. and i'm not sure what all that you need from it. i figured that backing up to the first id would be enough to go by which is what i pasted. So what exactly do you need and i will see if i can get it?

  • #8
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    please include at least everything up to and including the closing tags of the code you showed before.

  • #9
    New Coder
    Join Date
    Jan 2011
    Posts
    53
    Thanks
    17
    Thanked 1 Time in 1 Post
    deleted.
    Last edited by cbiblis; 07-18-2011 at 11:19 PM.

  • #10
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    It's getElementsByClassName and returns an array. You'll have to use the index [0] to access the first element of it
    Code:
    var go = s.getElementsByClassName(“box_title”)[0];

  • Users who have thanked devnull69 for this post:

    cbiblis (07-18-2011)

  • #11
    New Coder
    Join Date
    Jan 2011
    Posts
    53
    Thanks
    17
    Thanked 1 Time in 1 Post
    Quote Originally Posted by devnull69 View Post
    It's getElementsByClassName and returns an array. You'll have to use the index [0] to access the first element of it
    Code:
    var go = s.getElementsByClassName(“box_title”)[0];
    Ok thx for your time. i still can't get it to work and i am flustered. i will revisit this issue at a later time.

  • #12
    New Coder
    Join Date
    Aug 2011
    Location
    Sydney
    Posts
    26
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by cbiblis View Post
    Ok thx for your time. i still can't get it to work and i am flustered. i will revisit this issue at a later time.
    You're not using IE8.0 are you? You won't be able to reference the object by using getElementsByClassName in IE8.0.
    “Don't pray for lighter burdens, but for stronger backs.”
    Deals in Sydney

  • #13
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a script that dose this if I an find it..

  • #14
    New Coder
    Join Date
    Aug 2011
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    thanks.......
    Last edited by dhape; 08-29-2011 at 11:17 PM. Reason: question is already answered

  • #15
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    getElementsByClassName for IE:

    Code:
    // pass the class name 
    // optionally, also pass the "scope" you want to look in
    // optionally, also pass the tag names to limit the search to
    // if you omit the scope, then the code uses document
    function elementsByClassName( name, where, what )
    {
        if ( where == null ) where = document; // default scope is entire document
        if ( what == null ) what = "*"; // default is all tags
        var elems = where.getElementsByTagName(what);
        var results = [ ];
        for ( var e = 0; e < elems.length; ++e )
        {
            var elem = elems[e];
            if ( elem.className != null && elem.className == name ) results.push( elem );
        }
        return results;
    }
    You will get better efficiency by passing a scope and tag, but of course if you want to search all tags in the entire document, just omit those arguments. If you want to search the entire document but do want to limit to just one kind of tag, then explicitly code either null or document for the second argument.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •