0
I have an interesting problem and did not know this condition in IE. There is on the site I took to maintain, a call like this: document.getElementByID(...)
. Well, what happens is that IE is not getting the ID
and yes the Name
, because there is no ID and yes Name. Well, no Chrome
this does not work(correct). What I did, I changed the calls to: document.getElementsByName(...)
. Well, it should work and it doesn’t work. It makes that mistake on top of jquery-ui.min.js
:
Uncaught TypeError: a.plugins[n].push is not a function
This is the code of my js. The element is IFConsultaEmpresa_
:
if (pObjAsp != 'X') {
pagina = pTxtDiretorio + pObjAsp + '?pt=' + pTxtNomeFuncao + p_parametros;
var cp = new cpaint();
cp.set_transfer_mode('get');
cp.set_debug(false);
cp.call('../../atc/asp/atc0006c.asp', 'auxHistNavegacao', '', pCodFuncao, pTxtDiretorio, pTxtNomeFuncao, pNumeroIframe);
//torna o iframe invisivel
for (var i = 1; i <= qtd_iframe; i++) {
//eval('document.getElementById(\'IFConsultaEmpresa_' + i + '\').height = \'0%\';');
//Essa alteração para ByName foi necessária para funcionar no Chrome
eval('document.getElementsByName(\'IFConsultaEmpresa_' + i + '\').height = \'0%\';');
eval('document[\'all\'].IFConsultaEmpresa_' + i + '.style.display = \'none\';');
}
eval('boolIFrame = (IFConsultaEmpresa_' + pNumeroIframe + '.location == \'about:blank\')');
form01.ifram_carregado.value = 'IFConsultaEmpresa_' + pNumeroIframe;
if (pCodFuncao == 'ATC84.5.4' || pCodFuncao == 'ATC84.5.5' || pCodFuncao == 'ATC84.5.6' ||
pCodFuncao == 'ATC84.2.2.2' || pCodFuncao == 'ATC84.2.2.3' ||
pCodFuncao == 'ATC84.8.2.1' || pCodFuncao == 'ATC84.8.2.2'
) {
boolIFrame = true;
}
if (!boolIFrame & pNumeroIframe == '1') {
//iframe1 exclusívo para abertura/encerramento de atendimento - alteração novo atendimento
boolIFrame = true;
}
if (boolIFrame) {
eval('document[\'all\'].IFConsultaEmpresa_' + pNumeroIframe + '.src = \'' + pagina + '\';');
}
eval('document[\'all\'].IFConsultaEmpresa_' + pNumeroIframe + '.style.display = \'\';');
//eval('document.getElementById(\'IFConsultaEmpresa_' + pNumeroIframe + '\').height = \'50%\';');
//Colocado para funcionar no Chrome
eval('document.getElementsByName(\'IFConsultaEmpresa_' + pNumeroIframe + '\').height = \'50%\';');
}
}
try {
window.parent['roteiro'].location = '../../ace/ace040a.asp?cod_funcao=' + pCodFuncao;
} catch (e) {}
if (form01.ind_visualiza_roteiro.value == 'S') {
try {
parent.document['all'].td_roteiro.style.display = '';
} catch (e) { }
}
}
Here’s my html with that element:
<iframe width="100%" height="0%" scrolling="auto" name="IFConsultaEmpresa_<%Response.write intI%>" id="Iframe2" src="about:blank" frameBorder="no" style="display:" >
</iframe>
Behold IFConsultaEmpresa_
is the name and not the ID. How do I fix this?
A question. If you have the jQuery Libraries in the application, why not use them to avoid these cross browser problems?
– Erick Gallani
@Erickgallani, good afternoon. It’s added. That’s the question why you’re giving this stick. I have jquery includes. If I remove Byname and let Byid work
– pnet
then, you are using Document.getElementsByName which is native javascript. This comes with some problems, because each browser has a way of interpreting this instruction. This was one of the biggest motivators of creating jQuery. You can’t do something like $("[name='Ifconsultingbusiness' + i + ''']") ?
– Erick Gallani
I think you are not giving problem with jquery.ui but with some plugin that makes use of jquery.ui
– Erick Gallani
@Erickgallani, I can try to do that. Our big problem is this. The site is very large, we estimate more than 2000 pages, reports and etc. I only move in a small part of the site, written in ASP. However, there are many calls that are common to other parts of the site. That’s why it’s not so simple to exchange that for that. If this file is called only in this module, there are no problems there, but otherwise, then we would have to do a very detailed study to see the impact of the change.
– pnet
All right, I understand that kind of problem. Can you tell which or which components are used on this page in question you’re dealing with? Why neither jquery nor jquery.ui conflict with native javascript from any browser. So I think the real error is being masked.
– Erick Gallani
@Erickgallani, then, I talked to the leader here, that he has a macro view of the system, he told me that this js is only used in this module, so I will make this test calling by jquery and not by javascript. A question: What about Eval()? I place jquery inside Eval() or I kill Eval(()?
– pnet
keep inside the Val to minimize impacts on your project.
– Erick Gallani
@Erickgallani, replaces this expression: Eval('Document.getElementsByName('Ifconsultingcompaa_' + i + '). height = '0%';'); for this other, but I’m picking in quotes, because I think the parenthesis is wrong: Eval($('[name=Ifconsultingcompany_' + i + ']. height = 0%';'));
– pnet
try thus Eval('$("[name=Ifquerycompan_' + i + '"]. height = '0%';'));
– Erick Gallani
The error continues: Uncaught Typeerror: a.plugins[n]. push is not a Function. I did so: Eval('$("[name=IfqueryCompany_' + i + ']"). height = '0%';');
– pnet
@pnet, only one note
getElementByID
returns aElement
whilegetElementsByName
returns aNodeList
, then for your example to work, you would need to access the first element of the listdocument.getElementsByName(name)[0]
.– Tobias Mesquita
@Tobymosque, thank you very much. I had already done it at the suggestion of a colleague. I will close the post with the reply I gave, but many comments led me to the solution, mainly at the time of Gallani and this comment, also worth, but I had already done so at the suggestion of another colleague, even so thank you.
– pnet