code not working in mozilla (please help)

Discussion in 'JavaScript' started by sanjay_rajmane, Jun 1, 2007.

  1. #1
    Hi,
    I am trying code

    MTMOutputString += '<a href="#" onclick="parent.frames[\'text\'].toggleNav(true);return false"><img alt="Close" align="right" src="'+CloseMenuIconSrc+'" border="0" width="16" height="16"/></a>';

    MTMOutputString += '<a href="#" onclick="parent.frames[\''+MTMCodeFrame+'\'].location.reload();"><img alt="Refresh" align="right" src="'+RefreshMenuIconSrc+'" border="0" width="16" height="16"/></a><br>\n';


    This works fine in IE but for mozilla firefox giving error
    text has no properties
    I have tried
    window.top.frames['framename']
    parent.framename.toggleNav(true);
    But not works

    Please help me,
    Thanks in advance
     
    sanjay_rajmane, Jun 1, 2007 IP
  2. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The problem may be that "text" is a reserved JavaScript word. Or, is "text" the name of the frameset? There shouldn't be any JavaScript in the frameset document.

    onclick="parent.frames['text'].toggleNav(true);return false"

    And you shouldn't need to escape text.
     
    Mike H., Jun 1, 2007 IP
  3. sanjay_rajmane

    sanjay_rajmane Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I tried with changing name 'text' but not works,

    Actually I want to do is close frame on button click.

    It works first time when i click on button.
    But when i click second time it gives error
    has no properties.

    Please tell me if any other way to get frame
     
    sanjay_rajmane, Jun 1, 2007 IP
  4. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Close the frame?

    Please post the JavaScript function you are using to do that.
     
    Mike H., Jun 1, 2007 IP
  5. sanjay_rajmane

    sanjay_rajmane Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    function is like this

    function toggleNav ( inNav ) {

    alert('inNav1 : ' + inNav);
    if ( inNav ) {
    alert('inNav2 : ' + inNav);
    newHREF = parent.frames['text'].location.href;
    newHREF = removeGet( 'body', newHREF );
    newHREF = removeGet( 'view', newHREF );
    alert('newHREF1 : ' + newHREF);
    parent.location.href = addGet( newHREF, 'view=normal');
    } else {
    alert('inNav3 : ' + inNav);
    newHREF = location.href;
    newHREF = removeGet( 'body', newHREF );
    newHREF = removeGet( 'view', newHREF );
    alert('newHREF2 : ' + newHREF);
    location.href = addGet( newHREF, 'view=navigator');
    }


    return false;
    }

    Actually clicking on that button closes navigator, and will display other frame 100%.
     
    sanjay_rajmane, Jun 1, 2007 IP
  6. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    That's some 3rd party menu code, right? It's calling removeGet() and addGet() functions. Your problem is within one or both of those functions. I suggest you contact the vendor/author of that code. I have never heard of "closing" or "removing" a frame from a frameset. It seems to me that simply changing the height of a frame to 0px would be another way to achieve the effect.

    I can't help you with that 3rd party code.
     
    Mike H., Jun 1, 2007 IP
  7. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Sanjay:

    I received your PM. The following works for me in FF and IE, "opening" and "closing" the left hand frame.

    Frameset document:
    
    
    <head>
    <title>An<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    	<frameset cols="30%, 70%" >
    	<frame name="navFrame" scrolling="yes" src="nav.html">
    	<frame name="infoFrame" scrolling="yes" src="default.html">
    	</frameset>
    </html>
    
    Code (markup):
    navFrame, nav.html
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>y Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
    
    	function closeNav(){
    
    		parent.document.getElementsByTagName('frameset')[0].cols = "0%, 100%";
    	}
    
    	function openNav(){
    
    		parent.document.getElementsByTagName('frameset')[0].cols = "30%, 70%";
    	}
    
    
    </script>
    <style type="text/css">
    
    	 body {background-color:#eae3c6;margin-top:60px}
    	
    
    </style>
    </head>
    	<body>
    		<h1> Nav Frame </h1>
    		<br><br><br>
    		<br><br><br>
    		<a href="#" onclick="closeNav();return false"> Close </a>
    	</body>
    </html>
    
    Code (markup):
    infoFrame, default.html
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Any Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
    
    	
    </script>
    <style type="text/css">
    
    	 body {background-color:#eae3c6;margin-top:60px}
    	
    
    </style>
    </head>
    	<body>
    		<h1> Default </h1>
    		<br><br><br>
    		<br><br><br>
    		<a href="#" onclick="parent.frames['navFrame'].openNav();return false"> Open </a>
    	</body>
    </html>
    
    Code (markup):
     
    Mike H., Jun 2, 2007 IP
  8. sanjay_rajmane

    sanjay_rajmane Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thank You very much Mike.
    It works.
     
    sanjay_rajmane, Jun 3, 2007 IP
  9. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You're welcome, Sanjay. Good luck with your project.
     
    Mike H., Jun 4, 2007 IP