What is wrong with Focus on Firefox?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WH

    What is wrong with Focus on Firefox?

    <html>
    <head>
    <style type="text/css">
    html, body
    {
    overflow: hidden;
    }
    </style>
    </head>
    <body onload="showit( )" leftMargin="0" rightMargin="0" topMargin="0"
    marginwidth="0"
    marginheight="0 ">

    <iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%
    FRAMEBORDER="0" ></iframe>


    <script type="text/javascript" language="javas cript1.2">
    <!--
    function showit() {
    myframe.focus() ;
    //some other codes here

    }

    -->
    </script>
    </body></html>

    In IE, works perfectly, in firefox, not automatically focus.


  • Yann-Erwan Perio

    #2
    Re: What is wrong with Focus on Firefox?

    WH wrote:
    [color=blue]
    > myframe.focus() ;[/color]

    Where's the "myframe" variable defined and initialized? Ah, it's the ID
    of an element, not a variable - then use a standard way to get a handle
    to the element, not an IE-ism:-)

    Check the FAQ 4.41:

    <URL:http://jibbering.com/faq/#FAQ4_41>

    Comment

    • WH

      #3
      Re: What is wrong with Focus on Firefox?

      [color=blue]
      > WH wrote:
      >[color=green]
      > > myframe.focus() ;[/color]
      >
      > Where's the "myframe" variable defined and initialized? Ah, it's the ID
      > of an element, not a variable - then use a standard way to get a handle
      > to the element, not an IE-ism:-)
      >
      > Check the FAQ 4.41:
      >
      > <URL:http://jibbering.com/faq/#FAQ4_41>[/color]


      No, notwrking. Test this

      <html>
      <head>
      <style type="text/css">
      html, body
      {
      overflow: hidden;
      }
      </style>

      </head>
      <body onload="documen t.getElementByI d('myframe').fo cus();" leftMargin="0"
      rightMargin="0" topMargin="0" marginwidth="0" marginheight="0 ">

      <iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%
      FRAMEBORDER="0" ></iframe>

      </body></html>

      it is not auto focuced even with ById


      Comment

      • Yann-Erwan Perio

        #4
        Re: What is wrong with Focus on Firefox?

        WH wrote:

        [iframe focusing]
        [color=blue]
        > it is not auto focuced even with ById[/color]

        You're right, sorry.

        Firstly, I've referred you to something not applicable in the first
        place; the correct way to focus a frame is to give the frame a name, and
        then use
        frames["frameName"].focus();

        Secondly, I thought that the iframe could be focused, but I cannot
        manage to do it in Mozilla, even with the correct way and files from the
        same domain. I'm beginning to think this isn't doable, others might give
        us more insight.


        Regards,
        Yep.

        Comment

        • Lasse Reichstein Nielsen

          #5
          Re: What is wrong with Focus on Firefox?

          "WH" <kerry@whitehou se.gov> writes:
          [color=blue]
          > No, notwrking. Test this[/color]
          [color=blue]
          > <body onload="documen t.getElementByI d('myframe').fo cus();" leftMargin="0"
          > rightMargin="0" topMargin="0" marginwidth="0" marginheight="0 ">
          >
          > <iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%
          > FRAMEBORDER="0" ></iframe>[/color]

          Two points:

          The "focus" function exists on window objects, not (i)frame objects.
          Using "getElementById " will give you the iframe object, not the window
          object inside it. Sadly, there is no standard way to access that window
          (some browsers has the non-standard "frameElement.c ontentWindow",
          others only have "frameElement.c ontentDocument" ). To access frames
          by name, the best way is to use the frames collection (available as
          a global variable, i.e, a property of the window object):
          frames['myframe'].focus;

          Also, your iframe contains content from another domain. The security
          settings might, or might not, prevent you from interacting with the
          embedded page's window. Whether it works might depend on whether the
          embedded page has begun loading or not, when you access it.

          /L
          --
          Lasse Reichstein Nielsen - lrn@hotpop.com
          DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
          'Faith without judgement merely degrades the spirit divine.'

          Comment

          • WH

            #6
            Re: What is wrong with Focus on Firefox?

            > Two points:[color=blue]
            >
            > The "focus" function exists on window objects, not (i)frame objects.
            > Using "getElementById " will give you the iframe object, not the window
            > object inside it. Sadly, there is no standard way to access that window
            > (some browsers has the non-standard "frameElement.c ontentWindow",
            > others only have "frameElement.c ontentDocument" ). To access frames
            > by name, the best way is to use the frames collection (available as
            > a global variable, i.e, a property of the window object):
            > frames['myframe'].focus;
            >
            > Also, your iframe contains content from another domain. The security
            > settings might, or might not, prevent you from interacting with the
            > embedded page's window. Whether it works might depend on whether the
            > embedded page has begun loading or not, when you access it.
            >[/color]

            IE works every time. Mozzila never works. Here is the code based on
            frams.name, still not working.

            <html>
            <head>
            <style type="text/css">
            html, body
            {
            overflow: hidden;
            }
            </style>

            </head>
            <body onload="frames.['myframe'].focus();" leftMargin="0" rightMargin="0"
            topMargin="0" marginwidth="0" marginheight="0 ">

            <iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%
            FRAMEBORDER="0" ></iframe>

            </body></html>


            Comment

            • Lasse Reichstein Nielsen

              #7
              Re: What is wrong with Focus on Firefox?

              "WH" <kerry@whitehou se.gov> writes:
              ....[color=blue][color=green]
              >> frames['myframe'].focus;[/color][/color]
              ....[color=blue]
              > IE works every time. Mozzila never works. Here is the code based on
              > frams.name, still not working.[/color]
              [color=blue]
              > <body onload="frames.['myframe'].focus();" leftMargin="0" rightMargin="0"[/color]

              I can see it doesn't work. There is a "." too many.
              What error message does the browser give you?

              Have you validated your HTML?
              [color=blue]
              > <iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%[/color]

              I would probably add
              name="myframe"
              as well, so you have both "id" and "name". It won't hurt, and it might
              even work in some older browsers as well.

              /L
              --
              Lasse Reichstein Nielsen - lrn@hotpop.com
              DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
              'Faith without judgement merely degrades the spirit divine.'

              Comment

              • WH

                #8
                Re: What is wrong with Focus on Firefox?

                > "WH" <kerry@whitehou se.gov> writes:[color=blue]
                > ...[color=green][color=darkred]
                > >> frames['myframe'].focus;[/color][/color]
                > ...[color=green]
                > > IE works every time. Mozzila never works. Here is the code based on
                > > frams.name, still not working.[/color]
                >[color=green]
                > > <body onload="frames.['myframe'].focus();" leftMargin="0"[/color][/color]
                rightMargin="0"[color=blue]
                >
                > I can see it doesn't work. There is a "." too many.
                > What error message does the browser give you?
                >
                > Have you validated your HTML?
                >[color=green]
                > > <iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%[/color]
                >
                > I would probably add
                > name="myframe"
                > as well, so you have both "id" and "name". It won't hurt, and it might
                > even work in some older browsers as well.
                >[/color]

                Thanks. It is working. after I removed . after frames and added name=
                However it is not working in Opera yet. Opera 7.2


                Comment

                Working...