Solved

Window.focus - IE - Strange Problem

Posted on 2006-06-28
5
323 Views
Last Modified: 2008-03-17
Hello All

I'm having very strange problems with window focus in internet explorer.

1.  I've my default.aspx and in that I'm opening a new asp page called  Edi.aspx using
      Dim jscriptStr As String
                jscriptStr = "<script language=JavaScript> window.open('Edi.aspx','editorWin','height=5,width=555,left=300,top=300,toolbar=0,location=0, directories=0,status=0,menubar=0,scrollbars=no,resizable=0,titlebar=no');</script>"
                RegisterClientScriptBlock("clientScript", jscriptStr)

 In the Edi.aspx body tag I'm putting onload="javascript:top.focus();".

This is not working and the Edi.aspx is hiding behind the default.aspx. why is this happening? At the same time when I used this technique for a opening different page other.aspx its working.

Another big thing is- the above technique is working perfectly fine in firefox browser for both Edi.aspx and other.aspx.

I'm using IE.6.0.


2. Is there any way to access the controls in Edi.aspx from the default.aspx ( here Edi.aspx is opened from the default.aspx using window.open('Edi.aspx'))?


Thanks for your help
Aditya
0
Comment
Question by:adityaiiii
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
deanvanrooyen earned 500 total points
ID: 17005940
1 -  try remove ="javascript:top.focus();" from the body, are you trying to make the pop window modal?


2 - I think you mean this? or if you want it the other way round use the query string to pass params :
one way to do this is with javascript (if you use server.transfer there are other ways)
I have a default.aspx page with a textbox and hyperlink to pop a window edi.aspx, notice the javascript function popper - it tells the pop window what control to set:
default.aspx
<%@ Page Language="C#"  AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <link type="text/css" href="StyleSheet.css" media="all" rel="Stylesheet" />
    <style type="text/css">

   
    </style>
    <script type="text/javascript">

function popper(strField)
{
                        window.open('edi.aspx?field=' + strField ,'Popup','width=300,height=190');
}

</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" Height="20px" Width="155px"></asp:TextBox>
        <a href="javascript:;" onclick="popper('TextBox1');" title="Pick Date from Calendar">pop window</a>
    </div>
                              
    </form>
</body>
</html>

edit.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Edi.aspx.cs" Inherits="Edi" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body  bgcolor="black">
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Close" /></div>
    </form>
</body>
</html>

code behind edi cs

    protected void Button1_Click(object sender, EventArgs e)
    {
        string js = "<script type=\"text/javascript\">window.opener.form1.elements('" + Request.QueryString["field"] + "').value = '" + this.TextBox1.Text + "' ;this.window.close();</script>";

        Response.Write(js);
    }

this closes the popup and sets the text box on default.aspx to the text from the pop up window

this will should give you some starting points....

0
 
LVL 10

Expert Comment

by:SystemExpert
ID: 17006797
Hi,

You try like this

var newwindow;
function poptastic(url)
{
      newwindow=window.open(url,'name','height=400,width=200');
      if (window.focus) {newwindow.focus()}
}

or see thwe link

http://www.yourhtmlsource.com/javascript/popupwindows.html

Thanks
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17161348
try atlas it has an excellent modul window
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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

896 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

16 Experts available now in Live!

Get 1:1 Help Now