Solved

how to use Window Attributes

Posted on 2009-04-04
13
304 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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 Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 count occurrences of each item in an array.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now