Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to use Window Attributes

Posted on 2009-04-04
13
Medium Priority
?
316 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
12 Comments
 
LVL 92

Accepted Solution

by:
objects earned 750 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
Independent Software Vendors: 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!

 

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 750 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

824 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