...

View Full Version : Help with click() function



cbiblis
07-18-2011, 12:35 AM
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.

devnull69
07-18-2011, 03:32 PM
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?

cbiblis
07-18-2011, 08:15 PM
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?

devnull69
07-18-2011, 08:27 PM
You were talking about an iframe, but there is no iframe in your HTML code (at least you didn't show it).

cbiblis
07-18-2011, 08:34 PM
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?

devnull69
07-18-2011, 08:49 PM
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.

cbiblis
07-18-2011, 08:57 PM
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?

devnull69
07-18-2011, 09:17 PM
please include at least everything up to and including the closing tags of the code you showed before.

cbiblis
07-18-2011, 10:05 PM
deleted.

devnull69
07-18-2011, 10:14 PM
It's getElementsByClassName and returns an array. You'll have to use the index [0] to access the first element of it


var go = s.getElementsByClassName(“box_title”)[0];

cbiblis
07-18-2011, 10:53 PM
It's getElementsByClassName and returns an array. You'll have to use the index [0] to access the first element of it


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.

kunz
08-26-2011, 11:00 AM
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.

kashmir
08-28-2011, 12:43 PM
I have a script that dose this if I an find it..

dhape
08-28-2011, 07:45 PM
thanks.......

Old Pedant
08-28-2011, 08:00 PM
getElementsByClassName for IE:



// 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.

Curt
08-28-2011, 09:26 PM
those solution will make me grow up on coding :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum