Revisited "Solution Title: <body onload=resize window, position, no toolbars, no scrollbars"

Hi.

I'm a total gimp when it comes to javascript. I want to use the code by superslamwhich and hismightyness that was discussed in the topic "Solution Title: <body onload=resize window, position, no toolbars, no scrollbars" in Aug - Sep.

I tried to just paste it in to my document head and put the onLoad part in the body. It does not work for me however. Where does the code go? Does the script tag need to change? How does it now what window to open?
Like I said I know nothing and would really appreciate a straightforward explanation and copy/paste script.

This is what I did:

<head>
      <title>MyTitle</title>
      
      <script type='text/javascript'>
function SetWindow()
{
     url = "mypage2.htm"                //Set address of new window
  var height = 600                       //Set height
  var width = 800                        //Set width
  var name = "Popup"             //Set window name
  var top = 20                            //Set distance from top
  var left = 20                            //Set distance from bottom
  newwin=window.open(url, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
       // Cannot perform across all browsers
         this.focus();
         self.opener = this;
         self.close();
     }
}
</script>

</head>

<body onload="SetWindow();">

Need help now,
cheers.
iamcmagAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alambresCommented:
note that you got 1 { and 2 }. Remove one } and it'll go.
0
sajuksCommented:
//try this
<head>
     <title>MyTitle</title>
     
     <script type='text/javascript'>
function SetWindow()
{
     url = "mypage2.htm"                //Set address of new window
  var height = 600                       //Set height
  var width = 800                        //Set width
  var name = "Popup"             //Set window name
  var top = 20                            //Set distance from top
  var left = 20                            //Set distance from bottom
  newwin=window.open(url, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
       // Cannot perform across all browsers
        this.focus();
        self.opener = this;
        self.close();
     
}
</script>

</head>

<body onload="SetWindow();">
</body>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alambresCommented:
<html>
<head>
     <title>MyTitle</title>
     
     <script type='text/javascript'>
function SetWindow()
{
  url = "mypage2.htm"                //Set address of new window
  var height = 600                       //Set height
  var width = 800                        //Set width
  var name = "Popup"             //Set window name
  var top = 20                            //Set distance from top
  var left = 20                            //Set distance from bottom
  newwin=window.open(url, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
       // Cannot perform across all browsers
        this.focus();
        self.opener = this;
        self.close();
     
}
</script>

</head>

<body onload="SetWindow();">
</body>
</html>
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

iamcmagAuthor Commented:
Thanks guys.

Since both answers came in at exactly the same time I split the points between you. I hope that you will be alright with this.

Thanks again.
0
iamcmagAuthor Commented:
What does the name var actually do? I thougt that would be the title of the new window but it's not.
0
sajuksCommented:
var  stands for variable declaration.
Its the same as DIM in asp or the way you assign string, numeric in databases.In javascript all are defined as var.
0
sajuksCommented:
Dont let me down guys & gals. I told my friends that you people could do anything and everything.
:-)
0
sajuksCommented:
ignore the above comment, too many windows open posted in the wrong thread.
0
iamcmagAuthor Commented:
I understand what A var is I just don't see any real use of the name var in this example. I can't see that it does anything to my new window.
0
sajuksCommented:
//thanks to jbirk for the expln
Basically anytime you just come up with a new variable with declaring, it gets global scope, no matter where it is.
Consider a function
function test()
{for (i=0;i<5;i++)
  test2()
}

function test2()
{for(i=5; i>=0; i--)
  //do something
}

An inifite loop occured because when the second called function assigns something to i, that affects the i in the previous function. .

By simply adding var i; to the beginning of the test2(), it's fine:
function test2()
{var i;
 for(i=5; i>=0; i--)
  //do something
}

That makes the i variable local in scope and own't interfere with the previous i.
0
alambresCommented:
hey sajuks !!
I think you've missed the thread again
0
iamcmagAuthor Commented:
Thanks for everything
:0)
0
sajuksCommented:
hey alambres , dont think so , dont just look at the code check the explanation too :-)
0
alambresCommented:
oops, sorry, maybe I need a coffee :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.