Object Expected, need help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Z1P2
    New Member
    • Sep 2007
    • 23

    Object Expected, need help

    Line 22 Char 1 says object expected in the following code. For the life of me I can't figure out what it is. I'm sure I'm just overlooking some stupid bit of formatting or something.


    Code:
    <html><head>
    
    <script type="text/javascript">
    
    function ZoomIn() {
    if document.getElementById('MyIFrame').style.zoom!='100%' {
      newZoom= parseInt(MyIFrame.style.zoom)+10+'%';
          MyIFrame.style.zoom =newZoom;
    	ZoomInID=window.setTimeout("ZoomIn()",1000);}
    else  window.clearTimeout(ZoomInID);
      } 
    
    function ZoomOut() {
    if document.getElementById('MyIFrame').style.zoom!='50%' {
      newZoom= parseInt(MyIFrame.style.zoom)-10+'%';
          MyIFrame.style.zoom =newZoom;
    	ZoomOutID=window.setTimeout("ZoomIn()",1000);}
    else  window.clearTimeout(ZoomOutID);
      } 
    </script>
    </head><body>
    <iframe src="MyIFrame.htm" ID="MyIFrame" Name="MyIFrame" style="zoom:50%" onmouseover="ZoomIn();" onmouseout="ZoomOut();"></iframe>
    
    </body></html>
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by Z1P2
    Line 22 Char 1 says object expected in the following code. For the life of me I can't figure out what it is. I'm sure I'm just overlooking some stupid bit of formatting or something.


    Code:
    <html><head>
    
    <script type="text/javascript">
    
    function ZoomIn() {
    if document.getElementById('MyIFrame').style.zoom!='100%' {
      newZoom= parseInt(MyIFrame.style.zoom)+10+'%';
          MyIFrame.style.zoom =newZoom;
    	ZoomInID=window.setTimeout("ZoomIn()",1000);}
    else  window.clearTimeout(ZoomInID);
      } 
    
    function ZoomOut() {
    if document.getElementById('MyIFrame').style.zoom!='50%' {
      newZoom= parseInt(MyIFrame.style.zoom)-10+'%';
          MyIFrame.style.zoom =newZoom;
    	ZoomOutID=window.setTimeout("ZoomIn()",1000);}
    else  window.clearTimeout(ZoomOutID);
      } 
    </script>
    </head><body>
    <iframe src="MyIFrame.htm" ID="MyIFrame" Name="MyIFrame" style="zoom:50%" onmouseover="ZoomIn();" onmouseout="ZoomOut();"></iframe>
    
    </body></html>
    Did you forget to close the "()" in both "if" controls, or it is your code?

    Debasis Jana

    Comment

    • vee10
      New Member
      • Oct 2006
      • 141

      #3
      Hi ,
      Ur problem will be solved
      [CODE=javascript]if (document.getEl ementById('MyIF rame').style.zo om!='100%' )[/CODE] and

      [CODE=javascript]if (document.getEl ementById('MyIF rame').style.zo om!='50%' )[/CODE]
      in javascript if condition should have open and close braces

      syntax:
      [CODE=javascript]if(condition)
      {

      }

      else
      {

      }[/CODE]

      Originally posted by Z1P2
      Line 22 Char 1 says object expected in the following code. For the life of me I can't figure out what it is. I'm sure I'm just overlooking some stupid bit of formatting or something.


      Code:
      <html><head>
      
      <script type="text/javascript">
      
      function ZoomIn() {
      if document.getElementById('MyIFrame').style.zoom!='100%' {
        newZoom= parseInt(MyIFrame.style.zoom)+10+'%';
            MyIFrame.style.zoom =newZoom;
      	ZoomInID=window.setTimeout("ZoomIn()",1000);}
      else  window.clearTimeout(ZoomInID);
        } 
      
      function ZoomOut() {
      if document.getElementById('MyIFrame').style.zoom!='50%' {
        newZoom= parseInt(MyIFrame.style.zoom)-10+'%';
            MyIFrame.style.zoom =newZoom;
      	ZoomOutID=window.setTimeout("ZoomIn()",1000);}
      else  window.clearTimeout(ZoomOutID);
        } 
      </script>
      </head><body>
      <iframe src="MyIFrame.htm" ID="MyIFrame" Name="MyIFrame" style="zoom:50%" onmouseover="ZoomIn();" onmouseout="ZoomOut();"></iframe>
      
      </body></html>

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by vee10
        Hi ,
        Ur problem will be solved
        [CODE=javascript]if (document.getEl ementById('MyIF rame').style.zo om!='100%' )[/CODE] and

        [CODE=javascript]if (document.getEl ementById('MyIF rame').style.zo om!='50%' )[/CODE]
        in javascript if condition should have open and close braces

        syntax:
        [CODE=javascript]if(condition)
        {

        }

        else
        {

        }[/CODE]
        This is a syntactical problem.
        The error message never comes with Syntactical problem.
        Having runtime error it happens .............
        I think he mistyped.

        Debasis Jana

        Comment

        • Z1P2
          New Member
          • Sep 2007
          • 23

          #5
          Thanks, I changed it to:

          Code:
          <html><head>
          
          <script type="text/javascript">
          
          function ZoomIn() {
            if (document.getElementById('MyIFrame').style.zoom!=' 100%') {
              newZoom= (parseInt(MyIFrame.style.zoom)+10)+'%';
              MyIFrame.style.zoom =newZoom;
              ZoomInID=window.setTimeout("ZoomIn()",1000);
            } else {
              window.clearTimeout(ZoomInID);
            } 
          }
          
          function ZoomOut() {
            if (document.getElementById('MyIFrame').style.zoom!=' 50%') {
              newZoom= (parseInt(MyIFrame.style.zoom)-10)+'%';
              MyIFrame.style.zoom =newZoom;
              ZoomOutID=window.setTimeout("ZoomOut()",1000);
            } else {
              window.clearTimeout(ZoomOutID);
            } 
          }
          </script>
          
          </head><body>
          
          <iframe src="MyIFrame.htm" style="zoom:50%" ID="MyIFrame" onmouseover="ZoomIn();" onmouseout="ZoomOut();"></iframe>
          
          </body></html>
          But Now I get Lines 7, 8, 17, & 18 chars 5 'MyIFrame.style .zoom' is null or not an object which I can get rid of that by removing the .style from there, but it still won't do what I want it to, which is to change the zoom on the iframe. I must be missing something.

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Originally posted by Z1P2
            Thanks, I changed it to:

            Code:
            <html><head>
            
            <script type="text/javascript">
            
            function ZoomIn() {
              if (document.getElementById('MyIFrame').style.zoom!=' 100%') {
                newZoom= (parseInt(MyIFrame.style.zoom)+10)+'%';
                MyIFrame.style.zoom =newZoom;
                ZoomInID=window.setTimeout("ZoomIn()",1000);
              } else {
                window.clearTimeout(ZoomInID);
              } 
            }
            
            function ZoomOut() {
              if (document.getElementById('MyIFrame').style.zoom!=' 50%') {
                newZoom= (parseInt(MyIFrame.style.zoom)-10)+'%';
                MyIFrame.style.zoom =newZoom;
                ZoomOutID=window.setTimeout("ZoomOut()",1000);
              } else {
                window.clearTimeout(ZoomOutID);
              } 
            }
            </script>
            
            </head><body>
            
            <iframe src="MyIFrame.htm" style="zoom:50%" ID="MyIFrame" onmouseover="ZoomIn();" onmouseout="ZoomOut();"></iframe>
            
            </body></html>
            But Now I get Lines 7, 8, 17, & 18 chars 5 'MyIFrame.style .zoom' is null or not an object which I can get rid of that by removing the .style from there, but it still won't do what I want it to, which is to change the zoom on the iframe. I must be missing something.
            Is this "MyIFrame.style .zoom" a standard attribute.
            I don't know.
            Actually I am not very much familiar with CSS :-)
            Can't you do it using change the size of "IFrame"?
            Means ..... "style.heig ht" and "style.widt h".

            Debasis Jana

            Comment

            • Z1P2
              New Member
              • Sep 2007
              • 23

              #7
              Well, if I change just the height and width, then the contents of the frame won't shrink or grow with the frame, it will only change the viewable area. That's why I've got to change the zoom style somehow.

              The effect I'm going for here is to have a background image of (for example) a face, and the iframe will start out super-small, like around 2% of it's original size, and it will be placed over the pupil of the eye without borders, so that it almost looks like it's part of the picture, but when you mouse over the eye, it zooms the iframe in, which would contain a rotating ad such as a google adsense ad. I have done that already with just putting the final zoom size in the onmouseover event handler, but that doesn't provide the smooth zooming effect that I'm going for here.

              As far as I know, .style.zoom is ok... there's a script here: http://msdn2.microsoft.com/en-us/library/ms535169.aspx

              That uses it, and that script works (although they named their ID ozoom instead of MyIFrame, so in theirs it's ozoom.style.zoo m, but it should work the same).

              Comment

              • dmjpro
                Top Contributor
                • Jan 2007
                • 2476

                #8
                Originally posted by Z1P2
                Well, if I change just the height and width, then the contents of the frame won't shrink or grow with the frame, it will only change the viewable area. That's why I've got to change the zoom style somehow.

                The effect I'm going for here is to have a background image of (for example) a face, and the iframe will start out super-small, like around 2% of it's original size, and it will be placed over the pupil of the eye without borders, so that it almost looks like it's part of the picture, but when you mouse over the eye, it zooms the iframe in, which would contain a rotating ad such as a google adsense ad. I have done that already with just putting the final zoom size in the onmouseover event handler, but that doesn't provide the smooth zooming effect that I'm going for here.
                Then you have to wait for a CSS experts.

                Debasis Jana

                Comment

                • Z1P2
                  New Member
                  • Sep 2007
                  • 23

                  #9
                  Ok, so I changed and simplified the code, everything works now with no errors, with only one problem. If I mouse out before the iframe has finished zooming in, it stays at it's zoomed in size until I re-mouseover and mouseout again. If it absolutely has to work like that, ok, but I'd prefer it not to. I need one command to get this part to work as well, I need an IF statement that checks to see if the mouse is still over the object. Does such a thing exist? I know it's a long shot due to the redundancy between that and an onmouseout event, but I can hope, right?

                  Comment

                  Working...