[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating child windows from links and setting focus to child

Posted on 2001-07-02
4
Medium Priority
?
191 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 150 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

830 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