Solved

Creating child windows from links and setting focus to child

Posted on 2001-07-02
4
182 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
ID: 6246141
<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
ID: 6246145
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
ID: 6246163
<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
ID: 6246164
sorry, cross post
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Prevent site to open without the www. 9 61
sql to convert to date IF entry is in date format 4 75
Auto Submit on dropdown box 14 52
CDO.Message not able to send attachement 5 14
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

14 Experts available now in Live!

Get 1:1 Help Now