Solved

how to use Window Attributes

Posted on 2009-04-04
13
311 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

635 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