acao para preenchar campos de um frame
imaginem 2 frames:
<frameset rows="90,*" frameborder="NO" border="0" framespacing="0" cols="*">
<frame name="topFrame" scrolling="NO" noresize src="superior.htm" >
<frame name="mainFrame" src="https://www.coelce.com.br/">
</frameset>
e na pagina superior.htm tem o codigo de preenchimento abaixo, mas ao clicar o botao os campos nao sao preenchidos...
onde esta o erro?
<script type="text/javascript">
var auto ={
ctl00_ctl00_ctl00_ContentPlaceHolderDefault_ContentPlaceHolderDefault_Login_3_LoginView1_CadastroLogin1_UserName: "user@hotmail.com",
ctl00_ctl00_ctl00_ContentPlaceHolderDefault_ContentPlaceHolderDefault_Login_3_LoginView1_CadastroLogin1_Password: "senha",
fillerup: function() {
var all_inputs = document.getElementsByTagName('input');
var all_selects = document.getElementsByTagName('select');
var all_textareas = document.getElementsByTagName('textarea');
// selects
for (var i = 0, max = all_selects.length; i < max; i++) {
var sel = all_selects[i]; // current element
if (sel.selectedIndex != -1
&& sel.options[sel.selectedIndex].value) {
continue; // has a default value, skip it
}
var howmany = 1; // how many options we'll select
if (sel.type == 'select-multiple') { // multiple selects
// random number of options will be selected
var howmany = 1 + this.getRand(sel.options.length - 1);
}
for (var j = 0; j < howmany; j++) {
var index = this.getRand(sel.options.length - 1);
sel.options[index].selected = 'selected';
// @todo - Check if the selected index actually
// has a value otherwise try again
}
}
// textareas
for (var i = 0, max = all_textareas.length; i < max; i++) {
var ta = all_textareas[i];
if (!ta.value) {
ta.value = this.getRandomString(10)
+ '\n\n'
+ this.getRandomString(10);
}
}
// inputs
for (var i = 0, max = all_inputs.length; i < max; i++) {
var inp = all_inputs[i];
var type = inp.getAttribute('type');
if (!type) {
type = 'text'; // default is 'text''
}
if (type == 'checkbox') {
// check'em all
// who knows which ones are required
inp.setAttribute('checked', 'checked');
/* ... ooor random check-off
if (!inp.getAttribute('checked')) {
if (Math.round(Math.random())) { // 0 or 1
inp.setAttribute('checked', 'checked');
}
}
*/
}
if (type == 'radio') {
var to_update = true;
// we assume this radio needs to be checked
// but in any event we'll check first
var name = inp.name;
var input_array = inp.form.elements[inp.name];
for (var j = 0; j < input_array.length; j++) {
if (input_array[j].checked) {
// match! already has a value
to_update = false;
continue;
}
}
if (to_update) {
// ok, ok, checking the radio
// only ... randomly
var index = this.getRand(input_array.length - 1);
input_array[index].setAttribute('checked', 'checked');
}
}
if (type == 'password') {
if (!inp.value) {
inp.value = this.getPassword();
}
}
if (type == 'text') {
if (!inp.value) {
// try to be smart about some stuff
// like email and name
if (inp.name.indexOf('name') != -1) { // name
inp.value = this.getRandomName() + ' ' + this.getRandomName();
} else if (inp.name.indexOf('email') != -1) { // email address
inp.value = this.getRandomString(1) + '@example.org';
} else {
inp.value = this.getRandomString(1);
}
}
}
}
},
getRandomString: function (how_many_words) {
if (!how_many_words) {
how_many_words = 5;
}
if (!this.words) {
this.words = this.blurb.split(' ');
}
var retval = '';
for (var i = 0; i < how_many_words; i++) {
retval += this.words[this.getRand(this.words.length) - 1];
retval += (i < how_many_words - 1) ? ' ' : '';
}
return retval;
},
getRandomName: function () {
if (!this.split_names) {
this.split_names = this.names.split(' ');
}
return this.split_names[this.getRand(this.split_names.length) - 1];
},
getPassword: function () {
// always use the same password
// in case there is a password confirmation
if (!this.password) {
this.password = 'secret';
}
return this.password;
},
getRand: function (count) {
return Math.round(count * Math.random());
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<center>
CLIQUE PARA PRENCHER OS CAMPOS
<form action="" onsubmit="return false;">
<button onclick="auto.fillerup()">
"CLICAR PARA PREENCHER"
</button>
</form>
</body>
</html>Discussão (2)
Carregando comentários...