Solved

Creating child windows from links and setting focus to child

Posted on 2001-07-02
4
181 Views
Last Modified: 2006-11-17
I have an asp page with a link on it. When the user clicks on it I need to open a child window and load another page in it, at the same time I need to change something on the current page where the link is there. I tried two methods, but both are not working the same way as I want. I tried to submit the form to itself in the onclick of the link and then create the child window in the submit procedure. It works but the problem is the focus will come back to the parent form, instead of the child form as I used submit. I tried an alternate thing, instead of posting the form to itself called the same form itself with a querystring in the href of the link and then used the window.open in the body of the page checking the query string value. It also works, but the problem is when I hit on the next button(which will load another page) on the parent and then hit on the browser's back button, the child window is again creating as the history still has the query string in it ? Is there any alternate mthod to achieve this ?
0
Comment
Question by:rsaji
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
msdixon earned 50 total points
Comment Utility
<a href="javascript:openNew()">click here</a>
<script>
function openNew()
{
  window.open('', 'windowName'); // window parameters would be the third parameter
  // haven't tested the following 2 lines
  document.forms[0].target = 'windowName';
  document.forms[0].submit();

  // change the current url
  window.location = 'newPage.asp';
}
</script>
0
 
LVL 8

Expert Comment

by:drittich
Comment Utility
Is something like this what you are looking for?

<html>
<head>
<script language="javascript">
    function DoStuff() {
        alert('doing something here');
        window.open('http://www.google.com');
    }
</script>


</head>
<body>
<a href="javascript:DoStuff()">click me to do some stuff</a>
</body>
</html>


You can put what ever you want done in place of the alert command.
0
 
LVL 4

Expert Comment

by:epeele
Comment Utility
<script language=javascript>

  function openChild(){
     var newWindow = window.open("some.asp","newWindow");
     
     lnkOpen.innerText = "Open Again";

     newWindow.focus();
 
  }
</script>


<a id=lnkOpen name=lnkOpen href="javascript:openChild();">Open Child</a>
0
 
LVL 4

Expert Comment

by:epeele
Comment Utility
sorry, cross post
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

11 Experts available now in Live!

Get 1:1 Help Now