Solved

how to use Window Attributes

Posted on 2009-04-04
13
308 Views
Last Modified: 2012-05-06
I am trying to use Window Attributes to control my pop up windows but for some reason I must be putting the Window Attributes  in the wronw place.
<html>
  <head>
    <title> JavaScript Blueprint </title>
    <script type="text/javascript">
        newWin = false;
        function OpenIt(TheUrl){
          if (newWin && !newWin.closed){
            newWin.location.href=TheUrl;
            newWin.focus();
          }
          else{
            newWin=window.open(TheUrl);
          }
        }
    </script>
  </head>
  <body onload="OpenIt('titleStatus.html')">
     <a href="javascript:OpenIt('http://www.Wiley.com','width=100,height=200,location=no,scrollbars=no,toolbar=no')">Books</a>
  </body>
</html>

Open in new window

0
Comment
Question by:WDJ98338
  • 6
  • 5
13 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 24070105

 
     JavaScript Blueprint
    <script type="text/javascript">
        newWin = false;
        function OpenIt(TheUrl, attrs){
          if (newWin && !newWin.closed){
            newWin.location.href=TheUrl;
            newWin.focus();
          }
          else{
            newWin=window.open(TheUrl, 'window name', attrs);
          }
        }
    </script>
 
 
     Books
 
0
 

Author Comment

by:WDJ98338
ID: 24070147
This did not work.

<html>
  <head>
    <title> JavaScript Blueprint </title>
    <script type="text/javascript">
        newWin = false;
        function OpenIt(TheUrl){
          if (newWin && !newWin.closed){
            newWin.location.href=TheUrl;
            newWin.focus();
          }
          else{
            newWin=window.open(TheUrl);
          }
        }
    </script>
  </head>
  <body onload="OpenIt('titleStatus.html')">
     <a href="javascript:OpenIt('http://www.msn.com','width=100,height=200,location=no,scrollbars=no,toolbar=no')">Books</a>
   
     
  </body>
</html>
0
 
LVL 92

Expert Comment

by:objects
ID: 24070156
you have to pass the attributes to the open call as i posted above

0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 

Author Comment

by:WDJ98338
ID: 24070213
ARE you saying it should be like this.

<html>
  <head>
    <title> JavaScript Blueprint </title>
    <script type="text/javascript">
        newWin = false;
        function OpenIt(TheUrl){
          if (newWin && !newWin.closed){
            newWin.location.href=TheUrl;
            newWin.focus();
          }
          else{
            newWin=window.open(TheUrl,'width=100,height=200,location=no,scrollbars=no,toolbar=no');
          }
        }
    </script>
  </head>
  <body onload="OpenIt('titleStatus.html')">
     <a href="javascript:OpenIt('http://www.msn.com',)">Books</a>
   
     
  </body>
</html>
0
 
LVL 92

Expert Comment

by:objects
ID: 24070218
if you always want the same attributes then yes
if you need to be able to specify them then use what i posted first


0
 

Author Comment

by:WDJ98338
ID: 24070241
This is what you posted first and the code did not work at all. This is just a test and all I want to do is see it work. If I can get it from you and cut and paste and run it and it works and I can see the change in the browse then I can see how the window attributes works.


<html>
  <head>
    <title> JavaScript Blueprint </title>
    <script type="text/javascript">
        newWin = false;
        function OpenIt(TheUrl, attrs){
          if (newWin && !newWin.closed){
            newWin.location.href=TheUrl;
            newWin.focus();
          }
          else{
            newWin=window.open(TheUrl, 'window name', 'width=100,height=200,location=no,scrollbars=no,toolbar=no');
          }
        }
    </script>
  </head>
  <body onload="OpenIt('titleStatus.html', '')">
     <a href="javascript:OpenIt('http://www.Wiley.com','width=100,height=200,location=no,scrollbars=no,toolbar=no')">Books</a>
  </body>
</html>
0
 
LVL 92

Expert Comment

by:objects
ID: 24070253
that is not what I posted :)

0
 

Assisted Solution

by:WDJ98338
WDJ98338 earned 0 total points
ID: 24070320
Thanks for all your help and the many attempts to try to get me to understand what you were trying to get me to see, but I accomplished it on my own.


Thanks

<html>
<head>
      <title>Opening a Window</title>
      <script language='javascript' type="TEXT/javascript">
      
      function newWindow() {
            msnWindow = window.open('http://www.msn.com', 'msnWin', 'width=330,height=250, menubar=yes, status=yes')
      }

      </script>      
</head>
<body>
      
      <p><a href="javascript:newWindow()">Open</a></p>

</body>
</html>
0
 
LVL 92

Expert Comment

by:objects
ID: 24070370
I don't feel I was difficult at all.

0
 
LVL 54

Assisted Solution

by:b0lsc0tt
b0lsc0tt earned 250 total points
ID: 24072708
objects,
In my opinion you were being difficult.  Your first response was spot on.  Except for one error because of the example you used for 'window name' (IE doesn't like a value with a space) that was the perfect solution.  Your follow up comments and responses were less helpful though.  The final response at http:#a24070253 is really confusing since that is what you posted.  It isn't exact but the difference isn't relevant and didn't deserve the terse response.  You are a great expert and because we work in different areas I only know a little of how you work and your contributions here.  I would be glad to see you help more in Javascript and other web zones if you are interested and can help.  I just hope they will be more instructive and patient than the comments posted here.  I understand why the Asker said what he/she did and decided to finish this on their own.
WDJ98338,
There is no reason to delete this.  Although I understand your objection (as I mentioned above) part of this started with you.  You did not implement ALL the expert provided when you tried his first comment.  Your responses did not offer any details and were suprisingly brief.  What I mean is instead of saying "I tried in IE and got this result" you just posted "It didn't work" and copied code different from what the expert provided.  I mention this because I know you can get better results and better feedback from experts when you take the time to look carefully at what they posted and respond to it with details and thought.  In many cases doing this will make it so the expert will provide more detailed responses.  Not only will you get an answer and something that works but you would learn about the problem.
All,
My recommendation is PAQ.  The expert's first comment at http:#a24070105 should be part of the PAQ.  It showed the key errors and how to properly do what you wanted.  I have provide code with the typo fix below and mentioned why that comment didn't work as is in ALL browsers.  If the Asker's comment at http:#a24070320 is included in the PAQ then I feel that is appropriate.  If the Asker closed this with a B grade then that would be fine too.  I can't remember if grading is used when the Asker accepts one of their own comments but overall this is a B grade.
I hope my comments to the members above will not be taken personally.  I am just trying to help and offer the advise above as a third party.  If there are questions about any of this please let me know.  If the moderator wants me to make a more specific recommendation or close this myself then just let me know.
b0lsc0tt
EE Zone Advisor

<html>
  <head>
    <title> JavaScript Blueprint </title>
    <script type="text/javascript">
        newWin = false;
        function OpenIt(TheUrl, attrs){
          if (newWin && !newWin.closed){
            newWin.location.href=TheUrl;
            newWin.focus();
          }
          else{
            newWin= window.open(TheUrl, 'newWin', attrs);
          }
        }
    </script>
  </head>
  <body onload="OpenIt('titleStatus.html', '')">
     <a href="javascript:OpenIt('http://www.Wiley.com','width=100,height=200,location=no,scrollbars=no,toolbar=no')">Books</a>
  </body>
</html>

Open in new window

0
 
LVL 92

Expert Comment

by:objects
ID: 24073160
My responses are always fairly terse
0
 

Author Comment

by:WDJ98338
ID: 24113291
Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question