i have a javascript function that does work on Internet Explorer... but doesn't work on firefox nor google chrome.
Here's the example...
function CerrarFrame(src, id, tamArreglo)
{
parent.parent.document.getElementById("workSheet").src = src;
}
now the asp form
<frameset rows="41, *" frameborder="0" framespacing="0" name="frmMain" id="frmMain">
<frame name="topForm" src="Header.aspx" marginheight="0" marginwidth="0" scrolling="no" noresize>
<frameset cols="168,*" frameborder="0" framespacing="0" id="frmBody">
<frame name="frmMenu" id="frmMenu" src="MenuFrameNew.aspx?idUser=<%Response.Write(Session["idUser"]);%>&administrator=<%Response.Write(Session["administrator"]);%>&idCorp=<%Response.Write(Session["idCorporative"]);%>&file=<%Response.Write(Session["fileLogo"]);%>" marginheight="0" marginwidth="0" scrolling="no" noresize>
<frameset id="frmContent" name="frmContent" rows="*,21" frameborder="0" framespacing="0">
<frame name="workSheet" marginheight="0" marginwidth="0" src="Body.aspx" scrolling="auto">
<frame name="btm" marginheight="0" marginwidth="0" src="footer.htm" scrolling="no">
</frameset>
</frameset>
</frameset>
This javascript works properly on IE, but when I use it on FireFox, I get this error:
TypeError: parent.parent.document.getElementById("workSheet") is null
Is there a way to work this around? Thanks
i have a javascript function that does work on Internet Explorer... but doesn't work on firefox nor google chrome.
Here's the example...
function CerrarFrame(src, id, tamArreglo)
{
parent.parent.document.getElementById("workSheet").src = src;
}
now the asp form
<frameset rows="41, *" frameborder="0" framespacing="0" name="frmMain" id="frmMain">
<frame name="topForm" src="Header.aspx" marginheight="0" marginwidth="0" scrolling="no" noresize>
<frameset cols="168,*" frameborder="0" framespacing="0" id="frmBody">
<frame name="frmMenu" id="frmMenu" src="MenuFrameNew.aspx?idUser=<%Response.Write(Session["idUser"]);%>&administrator=<%Response.Write(Session["administrator"]);%>&idCorp=<%Response.Write(Session["idCorporative"]);%>&file=<%Response.Write(Session["fileLogo"]);%>" marginheight="0" marginwidth="0" scrolling="no" noresize>
<frameset id="frmContent" name="frmContent" rows="*,21" frameborder="0" framespacing="0">
<frame name="workSheet" marginheight="0" marginwidth="0" src="Body.aspx" scrolling="auto">
<frame name="btm" marginheight="0" marginwidth="0" src="footer.htm" scrolling="no">
</frameset>
</frameset>
</frameset>
This javascript works properly on IE, but when I use it on FireFox, I get this error:
TypeError: parent.parent.document.getElementById("workSheet") is null
Is there a way to work this around? Thanks
Share Improve this question asked Mar 5, 2013 at 1:29 VictorVictor 1,10810 gold badges29 silver badges53 bronze badges 01 Answer
Reset to default 1It seems you want to change the src
attribute of the frame workSheet
. However, that frame doesn't have an id
but just a name
. That's why it fails in all browsers but IE: IE – at least some version of IE – doesn't make any difference between name
attribute and id
attribute, that's why it returns the object. You can either add an id
to the frame (as you have done with frmContent
) or using frames
collection, like:
parent.parent.frames["workSheet"].src = src;
That uses the name
. See: https://developer.mozilla/en-US/docs/DOM/window.frames.
Hope it helps.