Solved

how to use Window Attributes

Posted on 2009-04-04
13
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

739 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