javascript - how to use parent.parent.document.getElementById on firefox?? asp.net - Stack Overflow

i have a javascript function that does work on Internet Explorer... but doesn't work on firefox no

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 0
Add a ment  | 

1 Answer 1

Reset to default 1

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745362916a4624442.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信